Skip to content
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

datetime.utcnow() and datetime.now() return same value #506

Open
HimanshuVijay-Heyday opened this issue Jun 29, 2023 · 1 comment
Open

Comments

@HimanshuVijay-Heyday
Copy link

HimanshuVijay-Heyday commented Jun 29, 2023

I am not in UTC timezone.

Normally:

>>> datetime.utcnow().timestamp() - datetime.now().timestamp()
25199.999709129333

with freeze_time:

>>> with freeze_time('2012-01-14'):
...     datetime.utcnow().timestamp() - datetime.now().timestamp()
... 
0.0

Isn't this wrong ?! freeze_time should preserve the timezone offset.

@tamird
Copy link

tamird commented Apr 25, 2024

I think this happens because freeze_time takes an optional tz_offset argument that defaults to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants