kennethreitz/maya

fallback timezone for parse() should be local timezone not UTC

Owyn opened this issue · 0 comments

Owyn commented

Is your Feature Request related to a problem? Please describe.

Trying to parse ebay item dates, e.g.
Aug-3 12:23, but it considers them UTC 0

Describe the solution you'd like
When there is no timezone clearly specified - use local timezone

Describe alternatives you've considered
I have tried:

print(datetime.datetime.now(datetime.timezone(datetime.timedelta(0))).astimezone().tzinfo)
RTZ 2 (зима)

maya.parse(item_date, print(datetime.datetime.now(datetime.timezone(datetime.timedelta(0))).astimezone().tzinfo), true).datetime().isoformat()

but RTZ is not supported

maya.parse(item_date, "UTC"+time.strftime("%z"), true).datetime().isoformat()
and
maya.parse(item_date, "UTC"+time.strftime("%z").replace("0",""), true).datetime().isoformat()

but both UTC+0300 and UTC+3 formats also aren't supported

Additional context
maybe add "Local" timezone value to use at least? but I still think it should use the local one when there is none specified

from tzlocal import get_localzone

maya.parse(item_date, get_localzone().key)
maya.when(item_date, get_localzone().key)

worked for me in the end