xmlrpclib date times and a trailing Z

Travis Parks jehugaleahsa at gmail.com
Fri Nov 11 19:20:09 EST 2011


I am trying to connect to Marchex's a call tracking software using
xmlrpclib. I was able to get some code working, but I ran into a
problem dealing with transfering datetimes.

When I construct a xmlrpclib.ServerProxy, I am setting the
use_datetime flag to indicate that I want to automatically convert
back and forth between date times in the datetime library.

I have a working version that doesn't use this flag, and I have to
convert from the xmlrpclib.DateTime type to the datetime.datetime type
manually, via string parsing.

The thing is, Marchex's API returns date's with a trailing Z, after
the time component. I did some research and this is supposed to be an
indicator that UTC was used. However, it doesn't seem like the
xmlrpclib likes it very much.

It looks like it is using this code internally: time.strptime(data, "%Y
%m%dT%H:%M:%S")

This code doesn't look like it handles time zones at all. I guess, is
there a way to tell xmlrpclib to include time zones when parsing date
times?

Thanks,
Travis Parks



More information about the Python-list mailing list