Skip to content

v2.11.1 pendulum_dt DateTime parsing shouldn't assume UTC when no timezone is specified #414

Description

@Interpause

In my use case, I need to fallback to the user's local timezone when a timezone-naive datetime str is given. However, the below results in UTC as the timezone, requiring ugly workarounds like detecting "+NN:NN" or "Z" if I want to replace naive timezone with local instead of UTC:

from pydantic import TypeAdapter
from pydantic_extra_types.pendulum_dt import DateTime
convert_datetime = TypeAdapter(DateTime).validate_python
print(repr(convert_datetime("2026-07-24")))
# DateTime(2026, 7, 24, 0, 0, 0, tzinfo=Timezone('UTC'))

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