localizedString method
Returns localized string representing this Duration in
HH h, MM m, SS s
format.
MM
part is omitted if this Duration is less than an one minute.
HH
part is omitted if this Duration is less than an one hour.
Implementation
String localizedString() {
var microseconds = inMicroseconds;
if (microseconds < 0) microseconds = -microseconds;
var hours = microseconds ~/ Duration.microsecondsPerHour;
microseconds = microseconds.remainder(Duration.microsecondsPerHour);
var minutes = microseconds ~/ Duration.microsecondsPerMinute;
microseconds = microseconds.remainder(Duration.microsecondsPerMinute);
var seconds = microseconds ~/ Duration.microsecondsPerSecond;
microseconds = microseconds.remainder(Duration.microsecondsPerSecond);
String result = '$seconds ${'label_duration_second_short'.l10n}';
if (minutes != 0) {
result = '$minutes ${'label_duration_minute_short'.l10n} $result';
}
if (hours != 0) {
result = '$hours ${'label_duration_hour_short'.l10n} $result';
}
return result;
}