pyrax
pyrax copied to clipboard
StorageObject method 'last_modified' inconsistently returns UTC or naive timestamp
Snippet:
obj_list = cont.get_objects()
for obj in obj_list:
print "%s\t\t%s\t\t%s" % (obj.name, obj.total_bytes, obj.last_modified)
dt = dateutil.parser.parse(obj.last_modified)
dt = dt.astimezone(dateutil.tz.tzutc())
print dt
now = datetime.now(dateutil.tz.tzutc())
print now
duration = now-dt
print duration.days
Output:
I'm not able to reproduce this. Does this happen consistently, or more or less randomly?
It happens randomly, it seems. I've had it work several times in a row, and then not work several times in a row. By "work" and "not work" I mean I was specifically looking for a UTC aware return. If you take my code snippet and run it say 50 times in a row, you should see different results several times in my experience.
I ran it over 10,000 times, and I did not receive back a single timezone-aware value; they were all in a format like 2012-12-10T15:32:42.373660
. IOW, "naive" datetime strings.
Could the difference be in how the objects were created/stored?