Open yemount opened 9 years ago
We generally recommend using package:intl
for complicated formatting of time and dates. It sadly doesn't support durations yet. I think that's where we should put the functionality when we implement it.
I assume that would be https://github.com/dart-lang/i18n/issues/332 then.
That would be it, yes. If something has to be written, that would be a better place for it than the SDK, since the intl
package can choose to support many different formats, where the SDK prefers to have just one canonical toString
with an accompagnying parse
, to allow storing as a string. It's not generally intended for displaying, because how to do that that is very much domain and use-case specific.
Currently Dart only supports limited duration formatting. The only way to get a formatted duration is through Duration.toString(): https://github.com/dart-lang/sdk/blob/bb7f3a7501e4e64fa149d9a42fae6625a88900a8/sdk/lib/core/duration.dart#L241
It'd be helpful to provide richer formatting options. For instance one that drops the hour string if hour is zero, or drops the unnecessary trailing 0s after the decimal point.