Skip to content
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

RelativeTimeFormat should support compound units #498

Open
sffc opened this issue Aug 17, 2020 · 5 comments
Open

RelativeTimeFormat should support compound units #498

sffc opened this issue Aug 17, 2020 · 5 comments
Labels
c: datetime Component: dates, times, timezones Proposal Larger change requiring a proposal s: comment Status: more info is needed to move forward

Comments

@sffc
Copy link
Contributor

sffc commented Aug 17, 2020

We got the following feature request from a Google Search client:

I'm working on a feature … that answers [what time will it be in X minutes/hours].

The UI spec calls for adding a phrase such as "one hour 20 minutes ago" or "in 45 minutes" to the template. In my use case I will have a timestamp for the "current time" … and the number of minutes relative to that that time.

What's the best way to format a relative timespan, such as "one hour 20 minutes ago" … ?

Backlink: https://yaqs.corp.google.com/eng/q/6499139655958528

Upstream: CLDR-14144

Also see: tc39/proposal-intl-duration-format#29

CC @younies

@sffc sffc added c: datetime Component: dates, times, timezones s: comment Status: more info is needed to move forward Proposal Larger change requiring a proposal labels Aug 17, 2020
@ryzokuken
Copy link
Member

The best way to move forward with this is to pursue the current plan of adding Temporal.Duration support for Intl.RelativeTimeFormat

@FrankYFTang
Copy link
Contributor

Additional idea is to add a reference time other than "now".

@FrankYFTang
Copy link
Contributor

It seems a good idea to champion a new proposal for Intl.RelativeTimeFormat v2 to enhance it for such a feature. I can also see additional different use case to use a different reference time for Intl.RelativeTimeFormat , such as "2 days after December 7, 1941" or "5 days, 23 hours, 54 minutes, and 41 seconds after April 11, 1970, 19:13:00 UTC"

@ryzokuken
Copy link
Member

ryzokuken commented Nov 7, 2023

@FrankYFTang do you think this would still be relevant after DurationFormat lands?

@sffc
Copy link
Contributor Author

sffc commented Nov 7, 2023

This issue is for a different proposal. DurationFormat only formats "floating" durations. It does not format durations relative to a point in time. See tc39/proposal-intl-duration-format#29 (comment) for some discussion on the differences between these formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: datetime Component: dates, times, timezones Proposal Larger change requiring a proposal s: comment Status: more info is needed to move forward
Projects
None yet
Development

No branches or pull requests

3 participants