-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add :date
and :time
functions
#570
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ | |
<validationRule id="timeZoneId" regex="[a-zA-Z/]+"/> | ||
<validationRule id="anythingNotEmpty" regex=".+"/> | ||
<validationRule id="iso8601" regex="\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}"/> | ||
<validationRule id="xmlDate" | ||
regex="-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"/> | ||
<validationRule id="xmlTime" | ||
regex="(([01][0-9]|2[0-3])(:[0-5][0-9]){2}(\.[0-9]+)?|24:00:00(\.0+)?)(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"/> | ||
|
||
<function name="datetime"> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat --> | ||
|
@@ -135,7 +139,36 @@ | |
</description> | ||
</option> | ||
</formatSignature> | ||
</function> | ||
|
||
<function name="date"> | ||
<description> | ||
Date formatting | ||
</description> | ||
|
||
<formatSignature> | ||
<input validationRule="xmlDate"/> | ||
<option name="style" values="full long medium short"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you going to describe in any amount of detail what the difference is between these four styles? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. 😉 🙈 This is what CLDR is for :-) On a higher level, we do not prescribe any output from any function. An implementation is free to implement options in anyway that it sees fit, including doing nothing at all. They just have to accept all of the options and values that they are required to accept by the spec. They can also extend the options as they see fit (we recommend using namespaced options when doing so). User will complain if the options don't work or work badly, but that's a problem for the implementer, not MFv2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This general strategy seems problematic. It means that whatever ICU implements will become the de-facto standard behavior. If ICU4X or ECMA or Ruby or Scala implement a different semantic meaning for the same formatting options, users will file bugs that their behavior is different than on the canonical ICU implementation, even if those other implementations are spec-compliant. It is the spec's role to prevent semantic differences between implementations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This general strategy already exists. FWIW, different versions of CLDR change what these shorthands mean or what specific data values are. Different locales handle these differently. CLDR changes formatting details all the time. I tend to tell developers not to worry about--or depend on--the specific output in any specific locale. But this is one reason why I love date skeletons and actively told users for the past five or eight years never to use the shorthand keywords. Tell the system what you want and DateTimePatternGenerator will build you the appropriate pattern in every locale. The translators don't have to mess with it and you'll never have that weird bug in some language in which I think I read into a lot of your comments this week a disconnect between MFWG's approach to formats and your expectations. MF2 does not implement any formatting at all. It delegates the formatting. Our options are user-facing and exist to let developers/translators communicate with the runtime what their formatting needs are. I hear the number or date formatter implementer in you--and value those comments hugely for keeping us honest. Many of our implementers, though, won't own the So... in this case, the keywords are widely recognized and CLDR even provides for them. But if Rust or Ruby want to impute different meanings or slightly different implementations, again, user's will complain if the results are wacky or wholly unexpected--or if they like the innovation, they'll complain to Annemarie et al about CLDR! Even CLDR has bugs in these cases. |
||
<description> | ||
The predefined date formatting style to use. | ||
</description> | ||
</option> | ||
</formatSignature> | ||
</function> | ||
|
||
<function name="time"> | ||
eemeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<description> | ||
Time formatting | ||
</description> | ||
|
||
<formatSignature> | ||
<input validationRule="xmlTime"/> | ||
<option name="style" values="full long medium short"> | ||
<description> | ||
The predefined time formatting style to use. | ||
</description> | ||
</option> | ||
</formatSignature> | ||
</function> | ||
|
||
<function name="number"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing at least one production here, unless you think
iso8601
covers that? (using a different syntax??)Is there some reason we can't reference XMLSchema directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you're referring to the
:datetime
operand, changing its validation rule here would be scope creep.To refer to external specs, we need language for how to do that, and that's not currently supported by
registry.dtd
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
xsd
recommends itself, except I'm not sure how compatible the number types are with JSON number (in fact, I'm sure they aren't compatible)I suspect we should make the registry's format completely unpromised in Tech Preview--even the use of XML. The normative bits are the default registry prose right now anyway. Let's solve this good and proper--and not over the weekend. I don't think anyone's implementation depends on the XML file now. We shouldn't encourage anyone to depend on it being any particular way in the future.
Thoughts?