Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent timezone parsing when parsing dates #7

Closed
AbelThorne opened this issue Mar 8, 2018 · 1 comment
Closed

Inconsistent timezone parsing when parsing dates #7

AbelThorne opened this issue Mar 8, 2018 · 1 comment

Comments

@AbelThorne
Copy link

When giving a date math expression to datemath.dm with a timezone argument there are two inconsistent behiavors regarding timezone parsing:

  • if there is a now in the expression, the timezone is parsed using the Arrow.to() method. This method accepts plenty of timezone formats (Europe/Paris, CET, +01:00, +01, +0100, UTC+1, etc.)
  • if there is a date to parse as anchor (or if the argument is already a fully qualified date without date math logic), the function datemath.helpers.parseTime() is used which uses in turn dateutil.tz.gettz() to parse the timezone. Although doing almost the same job, gettz() does not handle timezone in those formats: +01:00, +01, +0100.

A (very) quick fix would to replace in datemath.helpers.parseTime()
ts = ts.replace(tzinfo=tz.gettz(timezone))
by
ts = ts.replace(tzinfo=timezone)
since Arrow.replace() is perfectly happy with a string timezone expression and the behaviour would be perfectly consistent with Arrow.to()

nickmaccarthy added a commit that referenced this issue Oct 28, 2019
@nickmaccarthy
Copy link
Owner

Hi @AbelThorne , I went ahead and made this change for you in v1.4.9. Can you give the latest version a try and let me know if that fixes issue for you? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants