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

America/Sao_Paulo to UTC is -3:00 but pytz is returning -3:06 #56

Open
samuelrohr opened this issue Feb 23, 2021 · 2 comments
Open

America/Sao_Paulo to UTC is -3:00 but pytz is returning -3:06 #56

samuelrohr opened this issue Feb 23, 2021 · 2 comments

Comments

@samuelrohr
Copy link

As a checked before 1914 the timezone in Sao Paulo was -3:06 but it changed on that year.
The current version of pytz is returning the timezone as it's -3:06 from UTC instead of -3:00

You can check buy using this:

from datetime import datetime
import pytz

now = datetime(2021, 2, 3, 15, 0, 0, 0, pytz.timezone("America/Sao_Paulo"))
as_utc = now.astimezone(pytz.UTC)
@leogregianin
Copy link

You are not supposed to pass the result of pytz.timezone(…) to datetime, but should pass the datetime to its localize method.

from datetime import datetime
import pytz

now = datetime(2021, 2, 3, 15, 0, 0, 0)
dt_local = pytz.timezone("America/Sao_Paulo").localize(now)
as_utc = dt_local.astimezone(pytz.UTC)

@rooftoofwoof
Copy link

rooftoofwoof commented Sep 13, 2022

@samuelrohr We opted for zoneinfo instead. Hope that helps! :D https://docs.python.org/3/library/zoneinfo.html

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

3 participants