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'))
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: