-
Notifications
You must be signed in to change notification settings - Fork 10
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
parse-moment
doesn't work with CLDR pattern that includes z
?
#25
Comments
PS |
Hi Matthew, I'll give this a more thorough look in a few hours, but I have a strong suspicion that I didn't implement this on purpose, because (from a parsing perspective) That said, I could look to see how some other libraries implement this. (In the past, I've noticed that support for CLDR time zone parsing has been pretty lacking in most libraries. But this pattern, like pretty much all of CLDR, probably comes from ICU, so maybe I can figure out how they handle the Even if it isn't supported, though, it should not raise that particular exception, so that's a definite bug.
|
I suppose I was hoping that I see what you mean about ambiguous input from the outside world. Though is it possible for (require gregor)
(define pat "LLLL d, y z")
(~t (now/moment #:tz "America/Chicago") pat) ; "October 23, 2017 CDT"
(~t (now/moment #:tz "Asia/Taipei") pat) ; "October 24, 2017 GMT+8" |
@mbutterick You may be right. It could be that the CLDR rules eliminate all the possible ambiguity. I'll look into it this evening. Thanks! |
@mbutterick Of course, you still wouldn't get inverse functions out of that, since more than one TZ will map to GMT+8. In this case, Gregor could either return a moment that uses a UTC offset as the TZ, or else it could use the dreadful POSIX-compatible IANA TZs. (GMT+8 would correspond, if I'm not mistaken, to the UTC-8 IANA TZ -- for very weird historical reasons.) |
The CLDR rules seem to acknowledge the many ambiguities and then punt entirely on specifics: when parsing, it can be “especially complicated … to figure out what the user meant.” You don’t say. FWIW I don't mind if |
Yeah, so CLDR does mention that all times should round-trip under formatting and parsing, but not all time zones. So, we should always be able to parse a moment that will be |
@mbutterick Looking at the source again, there are a number of zone patterns that I think that I'm going to hold off on implementing the other parsing formats in Gregor. I've been working on a replacement for The current CLDR docs (I'm not sure how new this is) gives a sample algorithm for TZ parsing [http://unicode.org/reports/tr35/tr35-dates.html#Time_Zone_Parsing]. I kind of hate it, since it utterly ignores the pattern variable and, despite CLDR's advice, I think lenient parsing is a horrible default, but I might be able to do something with this algorithm. |
For whatever it's worth, I have a use case for wanting to parse with I am willing to help work on it, but I'll need guidance. |
How's this coming along? I periodically keep bumping into this issue. |
If you care, another user posted this link in #racket. https://pastebin.com/raw/NVffsgp3 They decided to work around the |
Bump... bumped into this today. I will do something hacky. |
According to the docs,
parse-moment
“Parsesstr
according topattern
, which uses the CLDR pattern syntax … If the input cannot be parsed as a moment,exn:gregor:parse
is raised.”z
is part of the CLDR pattern syntax. Yet passing a pattern withz
raises an error:Works:
Does not work:
Moreover, the error raised is not of type
exn:gregor:parse
, but ratherexn:misc:match
.The text was updated successfully, but these errors were encountered: