Skip to content

Incorrect Tz conversion adding extra minutes. #120

@legioz

Description

@legioz

Hi, I am having a problem related to Tz Conversion. I found that using pytz.timezone() with astimezone() method generates invalid timezone conversion adding some extra minutes to the final value.

Here is the example to replicate the problem:

import datetime
import pytz
from dateutil import tz

dt_sao_paulo = datetime.datetime(2024, 1, 1, 10, 10, tzinfo=pytz.timezone('America/Sao_Paulo'))
dt_utc = dt_sao_paulo.astimezone(pytz.utc)
print(dt_utc)
# same conversion with different lib
dt_sao_paulo = datetime.datetime(2024, 1, 1, 10, 10, tzinfo=tz.gettz('America/Sao_Paulo'))
dt_utc = dt_sao_paulo.astimezone(tz.UTC)
print(dt_utc)

The result printed:

2024-01-01 13:16:00+00:00
2024-01-01 13:10:00+00:00

The first one added 6 minutes to the final datetime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions