[Python-Dev] Re: [Python-checkins] python/dist/src/Lib xmlrpclib.py, 1.38, 1.39

Tim Peters tim.peters at gmail.com
Thu Feb 10 20:09:34 CET 2005


[fdrake at users.sourceforge.net]
> Modified Files:
>        xmlrpclib.py
> Log Message:
> accept datetime.datetime instances when marshalling;
> dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects
> 
> Index: xmlrpclib.py

...

> +            if datetime and isinstance(value, datetime.datetime):
> +                self.value = value.strftime("%Y%m%dT%H:%M:%S")
> +                return

... [and similarly later] ...

Fred, is there a reason to avoid datetime.datetime's .isoformat()
method here?  Like so:

>>> import datetime
>>> print datetime.datetime(2005, 2, 10, 14, 0, 8).isoformat()
2005-02-10T14:00:08

A possible downside is that you'll also get fractional seconds if the
instance records a non-zero .microseconds value.


More information about the Python-Dev mailing list