UUID timestamp generation is time-zone depenedent

51 views
Skip to first unread message

Conor McMaugh

unread,
May 23, 2012, 12:10:36 PM5/23/12
to pycassa-devel
pycass.util.convert_time_to_uuid uses the time.mktime call which
treats the passed timestamp as a timestamp with local timezone.
As my servers all have timezone set to UTC, this call works as I would
expect it to there.
However on my development machine which has the local timezone set
the function returns a different value for the timestamp portion of
UUID.
In my case all the datetimes used in the application are naive
datetimes that contain UTC values. The application is a web app on a
server, so the datetimes are generated at the client rather than on
the server itself, so the timezone that the server happens to be in
isn't relevant anyway.

Would it be better to change to convert_time_to_uuid to use
calendar.timegm() which expects a UTC time value rather than a local
time value?

Tyler Hobbs

unread,
May 23, 2012, 1:06:32 PM5/23/12
to pycass...@googlegroups.com
I agree that using calendar.timegm() would be a better behavior, but I don't think we should change the default behavior at this point.  I would prefer to offer some kind of switch or function parameter to achieve this.

I've opened https://github.com/pycassa/pycassa/issues/145 to look into this.

In the meantime, if you use calendar.timegm() on your datetime objects and pass the resulting timestamp in instead, it should do what you want.

--
Tyler Hobbs
DataStax

Reply all
Reply to author
Forward
0 new messages