Signal-Desktop/ts/util/formatDuration.ts

17 lines
346 B
TypeScript
Raw Permalink Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2019-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2019-10-03 19:03:46 +00:00
import moment from 'moment';
const HOUR = 1000 * 60 * 60;
export function formatDuration(seconds: number): string {
2019-10-03 19:03:46 +00:00
const time = moment.utc(seconds * 1000);
if (seconds > HOUR) {
return time.format('H:mm:ss');
}
return time.format('m:ss');
}