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