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

Inconsistency of conversion from 'UTC' to 'America/Sao_Paulo' timezone #67

Open
thiaagodev opened this issue Dec 22, 2021 · 1 comment

Comments

@thiaagodev
Copy link

There is an inconsistency when converting a datetime that is in UTC to pytz.timezone('America/Sao_Paulo'), instead of discounting 3 hours, it is only discounting 2 hours, the library is considering that Brazil is in daylight saving time, that no longer exists.

To get the correct conversion, you need to use pytz.timezone('Etc/GMT+3')

Fix the 'America/Sao_Paulo' to discount the hours in the correct way

@bxparks
Copy link

bxparks commented Dec 24, 2021

Drive-by comment:

  1. You should always include steps to reproduce the problem.

  2. I don't see any problems with America/Sao_Paulo:

from datetime import datetime, timedelta
from pytz import timezone
import pytz

sao_paulo_tz = timezone('America/Sao_Paulo')
pacific_tz = timezone('US/Pacific')

now = datetime.now(pytz.utc)
print(now)
pacific_dt = now.astimezone(pacific_tz)
print(pacific_dt)
sao_dt = now.astimezone(sao_paulo_tz)
print(sao_dt)

prints

2021-12-24 00:35:47.459424+00:00
2021-12-23 16:35:47.459424-08:00
2021-12-23 21:35:47.459424-03:00
  1. You are probably using pytz incorrectly. It has a few quirks. If you are able to, you should use zoneinfo (Python >= 3.9) or backports.zoneinfo (Python < 3.9) instead.

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