Dr-Blank.Vaani/lib/shared/extensions/duration_format.dart
2024-06-28 06:01:56 -04:00

18 lines
566 B
Dart

extension DurationFormat on Duration {
/// formats the duration of the book as `10h 30m`
///
/// will add up all the durations of the audio files first
/// then convert them to the given format
String get formattedBinary {
final hours = inHours;
final minutes = inMinutes.remainder(60);
return '${hours}h ${minutes}m';
}
}
extension OnlyTime on DateTime {
// in format HH:MM:ss
// padding with 0
String get time =>
'${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}';
}