Files
fredy/ui/src/services/time/timeService.js

18 lines
492 B
JavaScript
Raw Normal View History

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
*/
export function format(ts, showSeconds = true) {
return new Intl.DateTimeFormat('default', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
...(showSeconds ? { second: 'numeric' } : {}),
}).format(ts);
}
2025-09-03 14:22:04 +02:00
export const roundToHour = (ts) => Math.ceil(ts / (1000 * 60 * 60)) * (1000 * 60 * 60);