Open lbckmnn opened 1 year ago
https://github.com/spulec/freezegun/issues/348 https://github.com/spulec/freezegun/issues/204 https://github.com/spulec/freezegun/issues/89
All seem like basically the same thing?
I personally don't use freezegun anymore and have switched totally to time-machine, so I won't be spending more time with this.
Yes #204 is indeed the exact same issue.
Well, for my usecase i don't really care whether the passed time is utc or something else.
The problem is, that datetime.datetime.now()
returns the utc time once frozen and time.localtime()
doesn't. That is really inconsistent.
For my usecase, I need datetime.datetime.now()
and time.localtime()
to return the same time.
If you're not using pypy, I strongly recommend you switch to time-machine. It's quite easy to switch in my experience.
Yes, thats what i have done now. Thanks for the suggestion!
For folks migrating to time-machine because of this, you might wanna be aware of https://github.com/adamchainz/time-machine/issues/325#issuecomment-1427013470
When the time is frozen,
datetime.datetime.now()
anddatetime.datetime.utcnow()
return the same value, indicating that the timezone in this scenario is utc. However,time.localtime()
does not return the same value asdatetime.datetime.now()
anymore.time.localtime()
still takes into account the actual timezone of the system.Minimal example:
Output: