Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Jun 23, 2025

See #1082 for some of the discussion leading to this proposal.

This is an alternative to #1077, where instead of dateStyle and timeStyle 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:

Style options (#1077) This PR
: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 to dateLength (and dateFields to bring in the weekday), while timeStyle maps to timePrecision and timeZoneStyle.

This approach allows for the same locale-specific optionality as is currently in CLDR data, with e.g. ps and th 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 and timeStyle, 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 or dateFields=year-month, as well as additional options like yearStyle or fractionalSecondDigits, or even dateStyle and timeStyle. 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.

@eemeli eemeli requested review from aphillips, sffc and mihnita June 23, 2025 22:27
@sffc
Copy link
Member

sffc commented Jun 27, 2025

I'm okay with this, although we should have a discussion with the broader group on the option naming bikeshed.

@@ -187,19 +136,27 @@ All other _operand_ values produce a _Bad Operand_ error.

##### Options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider 12/24 time switches in this iteration? Currently we have whatever the locale defaults to, but some systems allow overrides. I realize that this is the minimal stopgap while we ponder the whole of date/time formatting...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is conveyed via the locale extension (a common tactic), then we don't need any override at the translator level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's in the Date and Time Override Options already, as hour12.

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

Successfully merging this pull request may close these issues.

4 participants