python - Expression of timezone offset - clarification appreciated -
something i'm working on requires localised times users around world. datetimes stored utc, converting them easy enough , have known, safe, point of reference, etc, etc.
however, how offset expressed making me scratch head moment.
>>> timezone.now() # get utc-stamped server time example datetime.datetime(2013, 5, 21, 16, 37, 54, 62598, tzinfo=<utc>) >>> eastern = pytz.timezone('us/eastern') # localise us/eastern >>> utc_dt.astimezone(eastern) datetime.datetime(2013, 5, 21, 12, 37, 54, 62598, tzinfo=<dsttzinfo 'us/eastern' edt-1 day, 20:00:00 dst>)
(that's line break in datetime output, make easier spot bit i'm on about.)
that expression of offset seems, well, bit on top. rather saying it's offset of -4h utc, looks it's saying it's minus 1 day plus 20:00 hours. right?
you're seeing repr
of pytz
timezone class, includes implementation details shouldn't matter when use in real life. if print
same object you'll see different:
>>> print utc_dt.astimezone(eastern) 2013-05-21 15:00:27.648000-04:00
Comments
Post a Comment