A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/320982.html below:

strptime() doesn't recognize BST as a valid timezone

strptime() doesn't recognize BST as a valid timezone strptime() doesn't recognize BST as a valid timezoneAdam Monsen haircut at gmail.com
Wed Sep 14 18:31:45 EDT 2005
I'm unable to parse the following date string using time.strptime():
"Wed Sep 14, 2005 5:07 PM BST"

Format: "%a %b %d, %Y %I:%M %p %Z"

I tried changing the locale and using time.tzset(), but no luck. Is
there anyone in London (or some other BST location) that would try
running the following code?

import time
date_str = "Wed Sep 14, 2005 5:07 PM BST"
format = "%a %b %d, %Y %I:%M %p %Z"
time.strptime(date_str, format)

I get: "ValueError: time data did not match format: ..."

NOTE: there is a workable solution to getting this date into the proper
timezone ('Europe/London'), but I'm still unable to parse the 'BST'
part, even after setting the locale to en_GB.utf8 and the timezone to
'Europe/London'. Here's a solution to "zoning" naive date strings:
http://snipurl.com/hoqz (full url:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/ce4909280561458b/
).

I did notice that the Python docs mention %Z is deprecated, so
http://snipurl.com/hoqz is possibly the best solution available for
now.

Thoughts?

--
Adam Monsen
http://adammonsen.com/


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4