<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Hi there,</span><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">First of all, please forgive me if I wrote to the wrong mailing-list, I&#39;d appreciate if you could redirect me to the correct one.</div>



<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">


I&#39;m working on a software in Japan, and need to handle dates in Gregorian format as well as <a href="http://www.i18nguy.com/l10n/emperor-date.html" style="color:rgb(17,85,204)" target="_blank">japanese emperor date</a>.</div>



<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Because I saw in the <a href="http://docs.python.org/library/locale.html?highlight=locale#locale" style="color:rgb(17,85,204)" target="_blank">locale doc</a> the following:</div>



<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><tt style="background-color:transparent;padding-top:0px;padding-right:1px;padding-bottom:0px;padding-left:1px;font-size:0.95em">locale</tt>.<tt style="background-color:transparent;padding-top:0px;padding-right:1px;padding-bottom:0px;padding-left:1px;font-size:1.2em;font-weight:bold">ERA<br>



</tt>Get a string that represents the era used in the current locale.<br>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.</blockquote>



<dt style="line-height:20px;text-align:justify"><font face="sans-serif"><span style="font-size:0.8em"><a href="http://docs.python.org/library/locale.html?highlight=locale#locale.ERA" title="Permalink to this definition" style="color:rgb(198,15,15);text-decoration:none;font-size:0.8em;padding-top:0px;padding-right:4px;padding-bottom:0px;padding-left:4px" target="_blank"></a></span></font></dt>



<div><br></div><div>After searching for a way to use that ERA with strftime, I finally managed to get something: <a href="http://sprunge.us/QFdJ?py" style="color:rgb(17,85,204)" target="_blank">http://sprunge.us/QFdJ?py</a></div>



<div><br></div><div>The problem, as you can see in my paste, is that strftime will properly work using a %E directive, but strptime doesn&#39;t support that directive. </div><div>Effectively, when looking at the _strptime module, I can see that the TimeRE class doesn&#39;t have a E key in his base.__init__ dictionary. </div>

<div>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&#39;t get any result.</div>

<div><br></div><div>This is really surprising that I&#39;m able to convert gregorian to emperor date, but that the contrary isn&#39;t possible. </div><div>I wonder if a patch couldn&#39;t be written for that. Or if I missed something that allow to convert emperor dates to gregorian without strptime. </div>

<div>I Tried dateutil.parser, but it doesn&#39;t work as well, giving a ValueError: unknown string format for parser.parse(&quot;昭和60&quot;)</div>

<div><br></div><div>Any help would be appreciated, thanks in advance for your time.</div></div><div><br></div>-- <br>Cheers,<br>Adrien LEMAIRE<div>Engineer @Aquasys<br><div><a href="http://gplus.to/Fandekasp" target="_blank">Google+</a>  <a href="http://vizualize.me/adrien.lemaire" target="_blank">CV</a></div>



<div><br></div></div><br>