2025-12-11 10:40:55 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025 by Christian Kellner.
|
|
|
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2025-10-05 14:23:32 +02:00
|
|
|
export function format(ts, showSeconds = true) {
|
2021-01-21 16:09:23 +01:00
|
|
|
return new Intl.DateTimeFormat('default', {
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
month: 'numeric',
|
|
|
|
|
day: 'numeric',
|
|
|
|
|
hour: 'numeric',
|
|
|
|
|
minute: 'numeric',
|
2025-10-05 14:23:32 +02:00
|
|
|
...(showSeconds ? { second: 'numeric' } : {}),
|
2021-01-21 16:09:23 +01:00
|
|
|
}).format(ts);
|
|
|
|
|
}
|
2025-10-05 14:23:32 +02:00
|
|
|
|
2025-09-03 14:22:04 +02:00
|
|
|
export const roundToHour = (ts) => Math.ceil(ts / (1000 * 60 * 60)) * (1000 * 60 * 60);
|