time.strptime() for different languages
Adam Monsen
haircut at gmail.com
Tue Sep 13 19:02:30 EDT 2005
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 _strptime
_strptime._cache_lock.acquire()
_strptime._TimeRE_cache = _strptime.TimeRE()
_strptime._regex_cache = {}
_strptime._cache_lock.release()
This has been filed as Python bug #1290505. (
http://sf.net/support/tracker.php?aid=1290505 ) A full test case is
attached to that bug.
--
Adam Monsen
http://adammonsen.com/
More information about the Python-list
mailing list