Include :date, :datetime, and :time with minimal options #1083
+77
−122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.