mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 19:08:04 +01:00
Fix RangeError invalid timestamp
This commit is contained in:
17
ts/util/formatTimestamp.ts
Normal file
17
ts/util/formatTimestamp.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assertDev } from './assert';
|
||||
|
||||
export function formatTimestamp(
|
||||
timestamp: number,
|
||||
options: Intl.DateTimeFormatOptions
|
||||
): string {
|
||||
const locale = window.getPreferredSystemLocales();
|
||||
try {
|
||||
return new Intl.DateTimeFormat(locale, options).format(timestamp);
|
||||
} catch (err) {
|
||||
assertDev(false, 'invalid timestamp');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user