mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Fix dst offset calculation (#10357)
This commit is contained in:
parent
b910db4f05
commit
efaa95b742
@ -258,9 +258,7 @@ const getUTCOffset = (date: Date, timezone: string): number => {
|
||||
}
|
||||
|
||||
// Otherwise, calculate offset using provided timezone
|
||||
const utcDate = new Date(
|
||||
date.getTime() - date.getTimezoneOffset() * 60 * 1000,
|
||||
);
|
||||
const utcDate = new Date(date.getTime());
|
||||
// locale of en-CA is required for proper locale format
|
||||
let iso = utcDate
|
||||
.toLocaleString("en-CA", { timeZone: timezone, hour12: false })
|
||||
@ -274,7 +272,11 @@ const getUTCOffset = (date: Date, timezone: string): number => {
|
||||
target = new Date(`${iso}+000`);
|
||||
}
|
||||
|
||||
return (target.getTime() - utcDate.getTime()) / 60 / 1000;
|
||||
return (
|
||||
(target.getTime() - utcDate.getTime() - date.getTimezoneOffset()) /
|
||||
60 /
|
||||
1000
|
||||
);
|
||||
};
|
||||
|
||||
export function getRangeForTimestamp(timestamp: number) {
|
||||
|
Loading…
Reference in New Issue
Block a user