mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-07-18 11:02:15 +01:00
15fa8b03bf
Co-authored-by: Scott Nonnenberg <scott@signal.org>
29 lines
598 B
TypeScript
29 lines
598 B
TypeScript
// Copyright 2019 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import moment from 'moment';
|
|
|
|
import { HOUR } from './durations/constants.std.ts';
|
|
|
|
const HOUR_IN_SECONDS = 1000 * 60 * 60;
|
|
|
|
export function formatDuration(seconds: number): string {
|
|
const time = moment.utc(seconds * 1000);
|
|
|
|
if (seconds > HOUR_IN_SECONDS) {
|
|
return time.format('H:mm:ss');
|
|
}
|
|
|
|
return time.format('m:ss');
|
|
}
|
|
|
|
export function formatDurationInMs(ms: number): string {
|
|
const time = moment.utc(ms);
|
|
|
|
if (ms > HOUR) {
|
|
return time.format('H:mm:ss');
|
|
}
|
|
|
|
return time.format('m:ss');
|
|
}
|