From lemaire.adrien at gmail.com Wed Jul 4 01:57:13 2012
From: lemaire.adrien at gmail.com (Adrien LEMAIRE)
Date: Wed, 4 Jul 2012 08:57:13 +0900
Subject: [I18n-sig] problem strptime and locale
Message-ID:
Hi there,
First of all, please forgive me if I wrote to the wrong mailing-list, I'd
appreciate if you could redirect me to the correct one.
I'm working on a software in Japan, and need to handle dates in Gregorian
format as well as japanese emperor
date
.
Because I saw in the locale
doc
the
following:
locale.ERA
> Get a string that represents the era used in the current locale.
> Most locales do not define this value. An example of a locale which does
> define this value is the Japanese one. In Japan, the traditional
> representation of dates includes the name of the era corresponding to the
> then-emperor?s reign.
After searching for a way to use that ERA with strftime, I finally managed
to get something: http://sprunge.us/QFdJ?py
The problem, as you can see in my paste, is that strftime will properly
work using a %E directive, but strptime doesn't support that directive.
Effectively, when looking at the _strptime module, I can see that the
TimeRE class doesn't have a E key in his base.__init__ dictionary.
I tried to go and read the locale C code to understand what is this E
directive and how I could add it in the list, but couldn't get any result.
This is really surprising that I'm able to convert gregorian to emperor
date, but that the contrary isn't possible.
I wonder if a patch couldn't be written for that. Or if I missed something
that allow to convert emperor dates to gregorian without strptime.
I Tried dateutil.parser, but it doesn't work as well, giving a ValueError:
unknown string format for parser.parse("??60")
Any help would be appreciated, thanks in advance for your time.
--
Cheers,
Adrien LEMAIRE
Engineer @Aquasys
Google+ CV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: