secondsToTime static method
Implementation
static String secondsToTime(BuildContext context, int? totalSeconds) {
if (totalSeconds == null) return '';
final trans = KatLocales.of(context)!;
int days = (totalSeconds / (24 * 60 * 60)).floor();
totalSeconds %= (24 * 60 * 60);
int hours = (totalSeconds / (60 * 60)).floor();
totalSeconds %= (60 * 60);
int minutes = (totalSeconds / 60).floor();
int seconds = totalSeconds % 60;
final timeParts = <String>[];
if (days > 0) {
timeParts.add('${trans.lblDayRange(days.toString())},');
}
if (hours > 0) {
timeParts.add(trans.lblHours(hours));
}
if (minutes > 0) {
timeParts.add(trans.lblMinutes(minutes));
}
if (seconds > 0) {
timeParts.add(
'${minutes > 0 ? trans.lblAnd : ''} ${trans.lblSeconds(seconds)}',
);
}
return timeParts.join(' ').trim();
}