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

Some forms of PM indicator combined with time zone don't work #149

Open
klondikedragon opened this issue Oct 29, 2022 · 1 comment · May be fixed by #159
Open

Some forms of PM indicator combined with time zone don't work #149

klondikedragon opened this issue Oct 29, 2022 · 1 comment · May be fixed by #159

Comments

@klondikedragon
Copy link

This is a very helpful package, thank you!

Parsing 2018-09-30 09:09:09PM EST will produce a correct result (the same as 2018-10-01T01:09:09Z), but 2018-09-30 09:09:09 PM EST will be incorrect (it recognizes the PM but not the time zone -- it produces the time value of 2018-09-30T21:09:09Z).

@klondikedragon
Copy link
Author

It also looks like it doesn't properly recognize time zones like PMDT, PMST, and AMT where the time zone name shares the same prefix as PM/AM. (e.g., 2018-09-30 21:09:09 PMDT or 2018-09-30 21:09:09 PM PMDT or 2018-09-30 21:09:09 PM AMT). It looks like when it hits the first P it goes into the timeWsAMPMMaybe state, but then when it hits the M it thinks that it is definitely an AM/PM. At that point it could potentially 'look ahead' at the next rune and if it isn't the end and it's still an alpha character then assume it's a time zone, etc.
https://github.com/araddon/dateparse/blob/master/parseany.go#L1397

klondikedragon added a commit to itlightning/dateparse that referenced this issue Dec 13, 2023
Also disallow PM and AM from being specified twice in the string.

Fixes araddon#149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant