Skip to content

Instantly share code, notes, and snippets.

@plq
Created October 28, 2011 09:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save plq/1321994 to your computer and use it in GitHub Desktop.
email date inconsistency
import pytz
import email.utils
import time
from datetime import datetime
a = datetime.now(pytz.utc)
print email.utils.formatdate(time.mktime(a.timetuple()))
print email.utils.formatdate(time.mktime(a.utctimetuple()) - time.timezone + 1e-6 * a.microsecond)
print repr(a)
@plq
Copy link
Author

plq commented Oct 28, 2011

when i run this script i get:

Fri, 28 Oct 2011 07:56:14 -0000
datetime.datetime(2011, 10, 28, 9, 56, 14, 945831, tzinfo=<UTC>)

I'm running Python 2.7.2 on gentoo linux. details are:

dev-lang/python-2.7.2-r3  USE="berkdb examples gdbm ipv6 ncurses readline sqlite ssl threads tk (wide-unicode) wininst xml -build -doc"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment