Created
November 17, 2016 20:07
-
-
Save AlexJoz/321ba6dd0806c06ca8a0ab53d26ebe98 to your computer and use it in GitHub Desktop.
Get day of year from rfc2822 email time in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python2 | |
from email.utils import parsedate_tz | |
import datetime | |
z = parsedate_tz('Fri, 1 Jan 2016 17:58:28 +0700') | |
print z | |
print datetime.datetime.strptime('{}-{}-{}'.format(z[0],z[1],z[2]), '%Y-%m-%d').timetuple().tm_yday | |
output: | |
''' | |
(2016, 1, 1, 17, 58, 28, 0, 1, -1, 25200) | |
1 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment