mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
added use12HourFormat arg to format function
This commit is contained in:
parent
a1a4254504
commit
d6bb9bd153
@ -25,7 +25,12 @@ export const getNowYesterdayInLong = (): number => {
|
|||||||
* @param timezone: string
|
* @param timezone: string
|
||||||
* @returns string - dateTime or 'Invalid time' if unixTimestamp is not provided
|
* @returns string - dateTime or 'Invalid time' if unixTimestamp is not provided
|
||||||
*/
|
*/
|
||||||
export const formatUnixTimestampToDateTime = (unixTimestamp: number, locale: string, timezone: string): string => {
|
export const formatUnixTimestampToDateTime = (
|
||||||
|
unixTimestamp: number,
|
||||||
|
locale: string,
|
||||||
|
timezone: string,
|
||||||
|
use12HourFormat: boolean
|
||||||
|
): string => {
|
||||||
if (isNaN(unixTimestamp)) {
|
if (isNaN(unixTimestamp)) {
|
||||||
return 'Invalid time';
|
return 'Invalid time';
|
||||||
}
|
}
|
||||||
@ -35,10 +40,11 @@ export const formatUnixTimestampToDateTime = (unixTimestamp: number, locale: str
|
|||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
hour: '2-digit',
|
hour: use12HourFormat ? 'numeric' : '2-digit',
|
||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
second: '2-digit',
|
second: '2-digit',
|
||||||
timeZone: timezone,
|
timeZone: timezone,
|
||||||
|
hour12: use12HourFormat !== null ? use12HourFormat : undefined,
|
||||||
});
|
});
|
||||||
return formatter.format(date);
|
return formatter.format(date);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user