Brett Cannon fixed this bug last week. Thanks, Brett!
--
Adam Monsen
http://adammonsen.com/
--
http://mail.python.org/mailman/listinfo/python-list
One way I'm able to do further date parsing in other locales is to
switch the locale for LC_TIME, bust the _strptime regular expressions
manually, then call strptime() again. Here's a function to bust the
cache. This works for me, but your mileage may vary.
def bust_strptime_cache():
import _s
Figured this out. I thought I'd post my results in case it is helpful
to someone else.
--8<--
import locale, time
# save old locale
old_loc = locale.getlocale(locale.LC_TIME)
locale.setlocale(locale.LC_TIME, 'nl_NL')
# seems to be the
Strange, but I can't figure out how to switch back to the default
locale.
>>> import locale, datetime, time
>>> locale.setlocale(locale.LC_ALL, 'nl_NL')
'nl_NL'
>>> date = '10 augustus 2005 om 17:26'
>>> time.strptime(date, "%d %B %Y om %H:%M")
(2005, 8, 10, 17, 26, 0, 2, 222, -1)
>>> locale.setlo
Excellent! Thank you, Fredrik!
--
Adam Monsen
http://adammonsen.com/
--
http://mail.python.org/mailman/listinfo/python-list
Adam Monsen wrote:
> No, this doesn't seem to work, and I can't find anything in the
> documentation indicating that it should.
>
> >>> import os
> >>> os.getenv('LANG')
> 'nl_NL'
> >>> import time
> >>> time.strptime("10 augustus 2005 om 17:26", "%d %B %Y om %H:%M")
> Traceback (most recent call
No, this doesn't seem to work, and I can't find anything in the
documentation indicating that it should.
>>> import os
>>> os.getenv('LANG')
'nl_NL'
>>> import time
>>> time.strptime("10 augustus 2005 om 17:26", "%d %B %Y om %H:%M")
Traceback (most recent call last):
File "", line 1, in ?
File
Adam Monsen wrote:
> Anyone know of something that works like time.strptime(), but for
> other languages? Specifically, Dutch (ex: "31 augustus 2005, 17:26")
> and German?
>
> Thinking out loud... since "31 augustus 2005, 17:26" is only different
> by month name, I suppose I could just substitute
Anyone know of something that works like time.strptime(), but for
other languages? Specifically, Dutch (ex: "31 augustus 2005, 17:26")
and German?
Thinking out loud... since "31 augustus 2005, 17:26" is only different
by month name, I suppose I could just substitute the month name using
a translat