Keith Devens .com |
Sunday, October 12, 2008 | ![]() |
| Your best? Losers always whine about their best. Winners go home and fuck the prom queen. – John Mason (The Rock) | ||
|
| ← Red Tape Records | The simplest blog software? → |

Ran (http://blogish.org) wrote:
Keith (http://keithdevens.com/) wrote:
I dunno. It seems like it's essentially this:
date = rfc822.parsedate_tz(message['date'])
time.mktime(newdate[0:9])
vs this:
date = email.Utils.parsedate(message['date'])
date = list(date); date[8] = -1; date = tuple(d)
time.mktime(date)
I'm pretty sure you didn't need to use the int cast, but are you sure you needed the slice? Most importantly, are you sure that handles time zones correctly (actually, the problem I had was not with time zones as such, but with daylight savings time)? If I hadn't had to fix that daylight savings time problem my code would not have needed the middle line above. In any case, I'm not going to change it now since what I have now is tested.
Ran wrote:
What you have now is great
It's just that my host doesn't have
email.Utils
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.218s.
(Used 8 db queries)

Hey,
Cool script. I will probebly use it.
There is a much cleaner way to format the date. Try this:
import rfc822
date = "Fri, 07 May 2004 16:01:54 +0200" # this is what you get
newdate = rfc822.parsedate_tz(date)
newdate = int(time.mktime(newdate[0:9]))
# newdate is now a unix timetamp
print date
print time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(date))