<br><br><div class="gmail_quote">On Wed, Apr 2, 2008 at 11:42 AM, Christian Heimes <<a href="mailto:lists@cheimes.de">lists@cheimes.de</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Martin v. Löwis schrieb:<br>
<div class="Ih2E3d">> Can you please explain why this is an important problem?<br>
> Dates before 1900 have all passed long ago, so they shouldn't<br>
> occur that often in real applications.<br>
</div></blockquote><div><br>In the application where I needed it, the customer wanted to send/store dates for e.g. the date of birth of some people.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
</div>Does xmlrpc support dates for 1900? For historic dates the Julian Day</blockquote><div><br>The xmlrpc spec says dates should be sent in the following format:<br><br> <dateTime.iso8601>19980717T14:08:55</dateTime.iso8601><br>
1900 is a rather arbitrary limit with this format.<br><br>Note that the unpatched xmlrpclib is able to receive datetime objects with dates before 1900:<br>~/ /usr/bin/python2.5 ralf@red ok<br>
Python 2.5.2 (r252:60911, Mar 9 2008, 11:14:55) <br>[GCC 4.2.3 (Debian 4.2.3-2)] on linux2<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> import xmlrpclib, datetime<br>
>>> xmlrpclib.loads('<params>\n<param>\n<value><dateTime.iso8601>18500101T00:00:00</dateTime.iso8601></value>\n</param>\n</params>\n', use_datetime=True)<br>
((datetime.datetime(1850, 1, 1),), None)<br><br>Dumping however doesn't work:<br>>>> xmlrpclib.dumps((datetime.datetime(1850, 1, 1),))<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>
File "/usr/lib/python2.5/xmlrpclib.py", line 1080, in dumps<br> data = m.dumps(params)<br> File "/usr/lib/python2.5/xmlrpclib.py", line 623, in dumps<br> dump(v, write)<br> File "/usr/lib/python2.5/xmlrpclib.py", line 635, in __dump<br>
f(self, value, write)<br> File "/usr/lib/python2.5/xmlrpclib.py", line 725, in dump_datetime<br> write(value.strftime("%Y%m%dT%H:%M:%S"))<br> File "datetime.py", line 791, in strftime<br>
return _wrap_strftime(self, fmt, self.timetuple())<br> File "datetime.py", line 181, in _wrap_strftime<br> "methods require year >= 1900" % year)<br>ValueError: year=1850 is before 1900; the datetime strftime() methods require year >= 1900<br>
<br>This ValueError just shows an implementation detail.<br><br>Note that it's also possible to send and receive dates before 1900 using xmlrpclib.DateTime objects.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Number family (MJD or JDN) or Rata Die are more appropriate and much<br>
easier to use. I wish somebody could add both to the datetime module.<br>
<br> </blockquote></div>