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

parsing CEST #346

Open
cadoubs opened this issue Jun 6, 2021 · 2 comments
Open

parsing CEST #346

cadoubs opened this issue Jun 6, 2021 · 2 comments

Comments

@cadoubs
Copy link

cadoubs commented Jun 6, 2021

From the documentation:

julia> Dates.format(zdt, "yyyy-mm-dd HH:MM ZZZ")
"2015-08-06 22:25 CEST"

But parsing in the other side returns an error:

julia> ZonedDateTime("2015-08-06 22:25 CEST",DateFormat("yyyy-mm-dd HH:MM Z"))
ERROR: ArgumentError: Unable to parse string "2015-08-06 22:25 CEST" using format dateformat"yyyy-mm-dd HH:MM Z". Unable to parse date time. Expected directive DatePart(Z) at char 18
...

Whereas with Europe/Paris (which is normally equivalent to CEST), it works:

julia> ZonedDateTime("2015-08-06 22:25 Europe/Paris",DateFormat("yyyy-mm-dd HH:MM Z"))
2015-08-06T22:25:00+02:00

Any workaround except replace before applying ZonedDateTime ?

@omus
Copy link
Member

omus commented Jun 9, 2021

Unfortunately this needs to be handled on a case-by-case basis as time zone abbreviations are not guaranteed to be unique. What should be done however is allowing end users to pass in a dict which maps time zone abbreviations to time zone instances.

@cadoubs
Copy link
Author

cadoubs commented Jun 10, 2021

Thank you for your reply.

The parse function could detect possible multiple results and display an error in this case. The best example is CST (Central/China/Cuba Standard Time).

Passing a known location information as reference for users (North America or Central America, Asia , Caribbean) could be easy way (for users) to determine Time Zone in case of doubt. The suggested dictionary is also an interesting possibility.

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