mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
13 lines
480 B
Dart
13 lines
480 B
Dart
/// Returns the duration in the format "h:mm:ss" or "m:ss".
|
|
String secondsToDuration(int totalSeconds) {
|
|
final hours = totalSeconds ~/ 3600;
|
|
final minutes = (totalSeconds % 3600) ~/ 60;
|
|
final seconds = totalSeconds % 60;
|
|
|
|
if (hours > 0) {
|
|
return '${hours.toString().padLeft(1, '0')}:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
|
|
} else {
|
|
return '${minutes.toString().padLeft(1, '0')}:${seconds.toString().padLeft(2, '0')}';
|
|
}
|
|
}
|