[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Time Zone application after strptime?

Jim Carroll

3/7/2008 9:25:00 PM

It's taken me a couple of hours to give up on strptime with %Z for recognizing
time zones... but that still leaves me in the wrong zone:

def paypal_to_mysql_date(ppDate):
# a typical paypal date is 10:29:52 Feb 29, 2008 PST
date_parts = ppDate.split()
withouttz = " ".join(date_parts[:-1])

# eventually we need to apply the timezone
timezone = date_parts[-1]

dt = datetime.strptime(withouttz, "%H:%M:%S %b %d, %Y")
return dt.strftime("%Y-%m-%d %H:%M")


How can I use the "PST" (or any other time zone name) to adjust dt by the
correct number of hours to get it into UTC before storing in MySQL?

Thanks!