-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
freezegun doesn't take timezones into account in some cases #309
Comments
A workaround for the issue: # The timezone offset in seconds, add 10 seconds to make sure we don't
# accidently get the wrong hour
offset_seconds = (datetime.now() - datetime.utcnow()).seconds + 10
offset_hours = int(offset_seconds / 3600)
freeze_time = freezegun.freeze_time(tz_offset=offset_hours) |
By default, freezegun will freeze to the UTC time instead of the system's timezone so I think this is expected behavior. I believe this issue is a dupe of #89, but let me know if you don't think that is the case. |
I believe it's similar but different. That issue could also fix this issue, but for now the biggest problem is the inconsistency that some methods do and others do not take the timezone into account. The issue is that if I replace datetime.now with datetime.utcnow, it breaks without freezegun |
Okay. I am going to close this in favor of #89 then. As noted there, there are some backward-incompatibilities we would have to make to proceed. |
Simple testcase:
Results for me (I'm in GMT+2):
The text was updated successfully, but these errors were encountered: