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

intl package: add CLDR-based duration / age formatting #332

Open
DartBot opened this issue Jun 5, 2015 · 6 comments
Open

intl package: add CLDR-based duration / age formatting #332

DartBot opened this issue Jun 5, 2015 · 6 comments
Labels
P3 A lower priority bug or feature request package:intl type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="96" height="96"hspace="10"> Issue by seaneagan
Originally opened as dart-lang/sdk#11075


The intl package currently has unimplemented methods on DateFormat for this called formatDuration and formatDurationFrom. This is the wrong location for these APIs. Arbitrary DateFormat patterns don't match up to the corresponding CLDR data model.

The intlx package (http://pub.dartlang.org/packages/intlx) has DurationFormat which formats Durations, e.g. "5 minutes" or "5 min" and AgeFormat which formats DateTimes offset from now, e.g. "In 5 minutes" or "5 minutes ago" using CLDR data. See the following:

Demo: http://seaneagan.me/intlx/
Docs:
  http://seaneagan.me/intlx/docs/intlx/DurationFormat.html
  http://seaneagan.me/intlx/docs/intlx/AgeFormat.html

Proposal: move DurationFormat and AgeFormat to intl package and remove DateFormat.formatDuration/formatDurationFrom.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/5449880?v=3" align="left" width="48" height="48"hspace="10"> Comment by iposva-google


Added Area-Pkg, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/5479?v=3" align="left" width="48" height="48"hspace="10"> Comment by sethladd


Added Pkg-Intl label.

@DartBot DartBot added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jun 5, 2015
@nikitadol
Copy link

When will this be implemented?

@GZaccaroni
Copy link

Still no update on this?

@mosuem mosuem added type-enhancement A request for a change that isn't a bug P3 A lower priority bug or feature request and removed type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 20, 2022
@mosuem mosuem transferred this issue from dart-archive/intl Apr 18, 2023
@clragon
Copy link

clragon commented Feb 15, 2024

This issue is still relevant today.

These packages provide relative time (e.g. "5 days ago"):
https://pub.dev/packages/timeago
https://pub.dev/packages/relative_time

Their implementation is pretty good from what I can tell though it would be much nicer to have access to this right inside intl.

However, the only package I can find for directly formatting durations:
https://pub.dev/packages/duration
seems to be less complete.
Durations can be formatted but they cannot possibly be parsed back.
The package has no concept of a "DurationFormat" as we have for dates with "DateFormat".
The repository also appears to be unmaintained currently.

@mosuem
Copy link
Member

mosuem commented Feb 16, 2024

This is a long-term goal, pending unicode-org/icu4x#801 and the addition of duration formatting into ECMA402. We can then expose this through package:intl4x. It will not be implemented in package:intl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request package:intl type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants