Skip to content

TZ and zoneinfo support #26

Open
Open
@AndreyNikiforov

Description

@AndreyNikiforov

What is the correct way to convert datetime (utc) to [arbitrary] timezone? Looks like this lib supports neither zoneinfo module nor astimezone() method...

Example I would like to run in CircuitPython:

from datetime import timezone
LOS_ANGELES = ZoneInfo("America/Los_Angeles")
dt_utc = datetime(2020, 11, 1, 8, tzinfo=timezone.utc)

# Before the PDT -> PST transition
print(dt_utc.astimezone(LOS_ANGELES))

# After the PDT -> PST transition
print((dt_utc + timedelta(hours=1)).astimezone(LOS_ANGELES))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions