Time Zone application after strptime?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Carroll

    #1

    Time Zone application after strptime?

    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_par ts[:-1])

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

    dt = datetime.strpti me(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!


Working...