Index: Lib/xmlrpclib.py =================================================================== --- Lib/xmlrpclib.py (revision 62291) +++ Lib/xmlrpclib.py (working copy) @@ -180,6 +180,14 @@ def _stringify(string): return string +# Format datetime in iso8601 format. Prior methods ignored timezone +# information (Truncates microseconds, adds TZD, changes +00:00 to Z) +def _iso8601format(dt): + if dt.tzinfo: + return dt.tzinfo.normalize(dt.replace(microsecond=0)).isoformat() \ + .replace('+00:00', 'Z') + return dt.replace(microsecond=0).isoformat() + __version__ = "1.0.1" # xmlrpc integer limits @@ -355,7 +363,7 @@ def __init__(self, value=0): if not isinstance(value, StringType): if datetime and isinstance(value, datetime.datetime): - self.value = value.strftime("%Y%m%dT%H:%M:%S") + self.value = _iso8601format(value) return if not isinstance(value, (TupleType, time.struct_time)): if value == 0: @@ -772,7 +780,7 @@ if datetime: def dump_datetime(self, value, write): write("") - write(value.strftime("%Y%m%dT%H:%M:%S")) + write(_iso8601format(value)) write("\n") dispatch[datetime.datetime] = dump_datetime