freezegun
freezegun copied to clipboard
Fix inconsistency between timestamp and strftime
It fixes #343
Coverage decreased (-4.3%) to 89.068% when pulling 7df9a78ce2b0ab5a7e27b87bb0bca2ef380e37e1 on mkarys:fix-strftime into a57f61f4ed917b51749505ee627896ce7df89899 on spulec:master.
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 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?
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