-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add unanchored intervals #322
Comments
This is actually implemented in a different Stage 3 proposal: https://github.com/tc39/proposal-intl-relative-time
This is covered by unit formatting: https://github.com/tc39/proposal-unified-intl-numberformat When combining multiple such units, you can use Intl.ListFormat: |
That's what I was referring to.
These are separate features. What this issue is about is a combination of both specialized for time intervals. E.g. programmers shouldn't need to know the list of units involved. (I imagine one in 59 s, two in 61 s and possibly one or two, depending on an option, in 1.5 s. The number of units used may even be, especially for fractions, locale dependent.) I also take back the "two years and five days" example. I recalled the distinction in the SQL standard between year-month and day-time intervals which cannot be mixed (since months differ in number of days) and it occurred to me that ECMAScript should follow suit. |
There was some past discussion about DurationFormat, I think. Is this subsumed by unit formatting? I thought some formats for durations were not, e.g., time remaining watching a video, but the cases that this issue starts with may fit into the same larger framework. As for a high level API that removes the need for computations: we are generally focused on starting with low-level APIs here, to give application developers the most flexibility. |
Good point. Numeric durations are supported in ICU MeasureFormat (internally the implementation is a bit of a hacky wrapper around DateFormat), but not in the proposals I listed previously. |
FWIW, I might support a feature like |
Closing this as a duplicate of #47 |
The IntervalFormat issue postulates an API for creating strings like "3—5 May 2022". There's also a proposal for instances specified relatively, e.g. "two years and five days ago", "in 1 hour, 2 minutes and 1 second". There's a simpler and also commonly needed case that's missing: just "2 days", "two years and five days", "1 hour, 2 minutes and 1 second" (no "ago" or "in").
The text was updated successfully, but these errors were encountered: