mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-29 07:09:03 +03:00
Support timezones (#11434)
* Handle offset timezones * Fix previews loading * Cleanup * remove unused
This commit is contained in:
@@ -235,7 +235,10 @@ export const getDurationFromTimestamps = (
|
||||
* @param timezone string representation of the timezone the user is requesting
|
||||
* @returns number of minutes offset from UTC
|
||||
*/
|
||||
export const getUTCOffset = (date: Date, timezone: string): number => {
|
||||
export const getUTCOffset = (
|
||||
date: Date,
|
||||
timezone: string = getResolvedTimeZone(),
|
||||
): number => {
|
||||
// If timezone is in UTC±HH:MM format, parse it to get offset
|
||||
const utcOffsetMatch = timezone.match(/^UTC([+-])(\d{2}):(\d{2})$/);
|
||||
if (utcOffsetMatch) {
|
||||
@@ -259,10 +262,10 @@ export const getUTCOffset = (date: Date, timezone: string): number => {
|
||||
target = new Date(`${iso}+000`);
|
||||
}
|
||||
|
||||
return (
|
||||
return Math.round(
|
||||
(target.getTime() - utcDate.getTime() - date.getTimezoneOffset()) /
|
||||
60 /
|
||||
1000
|
||||
60 /
|
||||
1000,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user