mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-20 21:54:58 -04:00
27 lines
682 B
TypeScript
27 lines
682 B
TypeScript
import moment, { DurationInputArg1 } from 'moment';
|
|
import translate from 'Utilities/String/translate';
|
|
|
|
function formatShortTimeSpan(timeSpan: DurationInputArg1) {
|
|
if (!timeSpan) {
|
|
return '';
|
|
}
|
|
|
|
const duration = moment.duration(timeSpan);
|
|
|
|
const hours = Math.floor(duration.asHours());
|
|
const minutes = Math.floor(duration.asMinutes());
|
|
const seconds = Math.floor(duration.asSeconds());
|
|
|
|
if (hours > 0) {
|
|
return translate('FormatShortTimeSpanHours', { hours });
|
|
}
|
|
|
|
if (minutes > 0) {
|
|
return translate('FormatShortTimeSpanMinutes', { minutes });
|
|
}
|
|
|
|
return translate('FormatShortTimeSpanSeconds', { seconds });
|
|
}
|
|
|
|
export default formatShortTimeSpan;
|