Open DartBot opened 9 years ago
When will this be implemented?
Still no update on this?
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.
This is a long-term goal, pending https://github.com/unicode-org/icu4x/issues/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
.
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.