kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix the simpleLabel to round up/down at 50% mark
rodzic
6e8904e10c
commit
928870e12d
|
@ -81,24 +81,24 @@ extension DateTimeExtensions on DateTime {
|
|||
|
||||
extension DurationExtensions on Duration {
|
||||
String get simpleLabel {
|
||||
final days = (inHours / 24.0).round();
|
||||
if (days != 0) {
|
||||
return days == 1 ? '1 day' : '$days days';
|
||||
final days = inHours / 24.0;
|
||||
if (days >= 1) {
|
||||
return days.round() == 1 ? '1 day' : '${days.round()} days';
|
||||
}
|
||||
|
||||
final hours = (inMinutes / 60.0).round();
|
||||
if (hours != 0) {
|
||||
return hours == 1 ? '1 hour' : '$hours hours';
|
||||
final hours = inMinutes / 60.0;
|
||||
if (hours >= 1) {
|
||||
return hours.round() == 1 ? '1 hour' : '${hours.round()} hours';
|
||||
}
|
||||
|
||||
final minutes = (inSeconds / 60.0).round();
|
||||
if (minutes != 0) {
|
||||
return minutes == 1 ? '1 minute' : '$minutes minutes';
|
||||
final minutes = inSeconds / 60.0;
|
||||
if (minutes >= 1) {
|
||||
return minutes.round() == 1 ? '1 minute' : '${minutes.round()} minutes';
|
||||
}
|
||||
|
||||
final seconds = (inMilliseconds / 1000.0).round();
|
||||
if (seconds != 0) {
|
||||
return seconds == 1 ? '1 second' : '$seconds seconds';
|
||||
final seconds = inMilliseconds / 1000.0;
|
||||
if (seconds >= 1) {
|
||||
return seconds.round() == 1 ? '1 second' : '${seconds.round()} seconds';
|
||||
}
|
||||
|
||||
if (inMilliseconds != 0) {
|
||||
|
|
Ładowanie…
Reference in New Issue