-
-
Notifications
You must be signed in to change notification settings - Fork 35
Include :date, :datetime, and :time with minimal options #1083
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
Conversation
I'm okay with this, although we should have a discussion with the broader group on the option naming bikeshed. |
I've dropped the "day" option value from I've kept in |
@eemeli We can always add |
- `hour` | ||
- `minute` (default) | ||
- `second` | ||
- `timeZoneStyle` |
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.
timeZoneStyle or zoneStyle?
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.
timeZoneStyle
. As I mention in #1082 (comment),
I'd be fine with
timeZoneStyle
ortimeZoneDisplay
. Abbreviating out the "time" part would be a mistake -- it's not at all obvious to anyone who's not worked closely with datetime formatting that an unspecified "zone" is referring to a time zone [1].[1] Unscientifically just verified this by asking three non-developer relatives about the meaning of the last option in the example at the top post here. They were quite confused, until I changed the name to
timeZoneStyle
.
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.
The experimental ICU4X syntax uses zoneStyle
and the Rust API uses zone
spec/functions/datetime.md
Outdated
- `minute` (default) | ||
- `second` | ||
- `timeZoneStyle` | ||
- `never` (default) |
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.
Is the "never" string used elsewhere in MF2? Seems like "hidden" or something might make more sense in this context
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.
Yes, it's used for a number of number function options.
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.
A little discussion: "never" feels better when used as an adverb in context with always/never
spec/functions/datetime.md
Outdated
- `longGeneric` | ||
- `longOffset` | ||
- `short` | ||
- `shortGeneric` | ||
- `shortOffset` |
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.
Observation: these are the ECMA names, which are not exactly the same as the names in the experimental ICU4X JSON syntax.
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.
- `dateFields` | ||
- `weekday` | ||
- `day-weekday` | ||
- `month-day` | ||
- `month-day-weekday` | ||
- `year-month-day` (default) | ||
- `year-month-day-weekday` |
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.
Not super happy with mixing camel case and kebab case, but I don't really want the field sets to be in camel case
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.
The casing was a major point of contention in the ICU4X TC, which is one reason we ended up landing on YMD
. (I remember where I was when we had that discussion: I was in Helsinki walking to the Future Frontend speaker dinner)
- `fields` | ||
- `weekday` | ||
- `day-weekday` | ||
- `month-day` | ||
- `month-day-weekday` | ||
- `year-month-day` (default) | ||
- `year-month-day-weekday` |
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.
I think @eemeli removed the day
fieldset based on an offhand remark I made at a meeting in June that the data for that fieldset was not high quality.
But, there is data for that fieldset in CLDR. It is just the number like "15", and my comment was that I think it would be better as "the 15th". But that's not my prerogative: it is something CLDR should decide, and it has clearly taken the position that it should be just the integer (this is from en.xml):
<availableFormats>
<dateFormatItem id="Bh">h B</dateFormatItem>
<dateFormatItem id="Bhm">h:mm B</dateFormatItem>
<dateFormatItem id="Bhms">h:mm:ss B</dateFormatItem>
<dateFormatItem id="d">d</dateFormatItem>
<dateFormatItem id="E">ccc</dateFormatItem>
<dateFormatItem id="EBh">E h B</dateFormatItem>
<dateFormatItem id="EBhm">E h:mm B</dateFormatItem>
<dateFormatItem id="EBhms">E h:mm:ss B</dateFormatItem>
<dateFormatItem id="Ed">d E</dateFormatItem>
I have a similar complaint about day-weekday
, which I think should be "Monday the 15th", but the data currently says "15 Monday"
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.
@aphillips's comment above #1083 (comment) would indicate a similar sentiment.
Out of an abundance of caution, my preferred solution here would be to leave out day-weekday
as well from this PR, so that it may be discussed later.
Regarding options whose different values impact ICU4X data loading:
|
@sffc Given that you don't mention anything about the override options in your last comment, can we presume that those do not impose any data loading concerns? |
I've applied some updates following yesterday's discussion:
|
I was commenting on the options listed in #1083 (comment) which didn't mention the override options.
Separate question: May I ask why you want to use I already have an issue open for |
As discussed today, there are actually 3 places where information can be injected:
For example:
The constraints on each option are:
With this new terminology, I should clarify where each of the options lands:
"Preferred Bucket" is the bucket where I think the option should fit in order to be most future-proof. "Theoretically Feasible Bucket" is a bucket where the option could be implemented and still work with ICU4X's current data model. In other words, my position is:
|
Can you add a bit more info?
Does that mean that if the message specified Month+Day+Time+Weekday, it would move into bucket 2?
Does that mean that if the message specifies Month+Day+Time+Timezone, and the developer hasn't loaded "the translation for the user's locale"*, that the message formatting will fail? Or fallback to without the timezone? * I take it to mean not literally "the translation for the user's locale", meaning "English" for "en"))
Does "user" mean end-user (eg I enter in a date in a spreadsheet cell), or rather the caller (the code calling message format)? In either case, I'm confused. Suppose the code makes the following (pseudocode) call. userDate = 2025-07-21 formatMessage(message, userDate, userTime, userZone) Does that mean that no matter what the message is, this is in bucket 3? |
I'm putting options into buckets, not messages. The field set is always in bucket 1.
If the developer hasn't loaded the translation of the message into the user's locale, then they won't be able to instantiate their MessageFormatter.
What I meant was that the specific date, time, and time zone are provided at runtime, likely by an end user. We don't know what they are either at build time (bucket 1) or formatter creation time (bucket 2); we only know them at format time (bucket 3).
userDate, userTime, and userZone are provided in a call to formatMessage, meaning that those three options are ones that I would consider to be bucket 3. |
See #1082 for some of the discussion leading to this proposal.
This is an alternative to #1077, where instead of
dateStyle
andtimeStyle
we start with the following options::datetime
dateFields
dateLength
timePrecision
timeZoneStyle
:date
fields
length
:time
precision
timeZoneStyle
With these, we are able to represent each of the style option combinations rather succinctly:
:date style=short
:date length=short
:date style=medium
:date length=medium
:date style=long
:date length=long
:date style=full
:date fields=year-month-day-weekday length=long
:time style=short
:time precision=minute
:time style=medium
:time precision=second
:time style=long
:time precision=second timeZoneStyle=short
:time style=full
:time precision=second timeZoneStyle=long
:datetime dateStyle=short timeStyle=medium
:datetime dateLength=short timePrecision=second
For the most part,
dateStyle
maps todateLength
(anddateFields
to bring in the weekday), whiletimeStyle
maps totimePrecision
andtimeZoneStyle
.This approach allows for the same locale-specific optionality as is currently in CLDR data, with e.g.
ps
andth
including the era with the year, and many locales defaulting to including a dayperiod (am/pm) indicator in the time.The expectation here is that the options being provided here are sufficiently easy to use and understand without any external reference that we won't need to later introduce
dateStyle
andtimeStyle
, while providing a sufficient foundation for filling in the remaining details.This is not intended to be a complete solution for datetime formatting, but a step towards that. If we accept this, we will need to subsequently and separately consider additional option values like
timePrecision=minuteOptional
ordateFields=year-month
, as well as additional options likeyearStyle
orfractionalSecondDigits
, or evendateStyle
andtimeStyle
. They've all been left out of here to keep this as small as possible, while providing a cohesive whole for many date/time formatting needs.