freezegun icon indicating copy to clipboard operation
freezegun copied to clipboard

Fix inconsistency between timestamp and strftime

Open mkarys opened this issue 4 years ago • 4 comments

It fixes #343

mkarys avatar Jun 27 '20 21:06 mkarys

Coverage Status

Coverage decreased (-4.3%) to 89.068% when pulling 7df9a78ce2b0ab5a7e27b87bb0bca2ef380e37e1 on mkarys:fix-strftime into a57f61f4ed917b51749505ee627896ce7df89899 on spulec:master.

coveralls avatar Jun 27 '20 21:06 coveralls

I'm confused about the test... doesn't this test basically do nothing if run on a system with UTC as local time zone?

The test is very elegant, but it seems like it relies on a misfeature of freezegun.. or am I misunderstanding?

boxed avatar Jun 28 '20 13:06 boxed

@boxed yes, you right, it fixes cases that UTC is not local time zone, if UTC is local time zone it was okay without it. What misfeature of freezegun are you refer to?

mkarys avatar Jun 29 '20 15:06 mkarys

I don't think this is the right solution. It fixes the problem with "%s" but breaks strftime in general.

For example, running this with TZ='America/New_York':

import freezegun
from datetime import datetime

with freezegun.freeze_time("1970-01-01T00:00"):
    print(datetime(2010, 1, 1).strftime("%Y-%m-%dT%H:%M:%S"))
    # 2009-12-31T19:00:00

print(datetime(2010, 1, 1).strftime("%Y-%m-%dT%H:%M:%S"))
# 2010-01-01T00:00:00

pganssle avatar Jun 17 '21 20:06 pganssle