Skip to content

Instantly share code, notes, and snippets.

@AlexJoz
Created November 17, 2016 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexJoz/321ba6dd0806c06ca8a0ab53d26ebe98 to your computer and use it in GitHub Desktop.
Save AlexJoz/321ba6dd0806c06ca8a0ab53d26ebe98 to your computer and use it in GitHub Desktop.
Get day of year from rfc2822 email time in Python
#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