forked from Github/frigate
@@ -269,15 +269,6 @@ export const getUTCOffset = (
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the minute offset in seconds of the current timezone from UTC.
|
||||
* Any timezones with an offset in hours will return 0,
|
||||
* any timezones with an offset of 30 or 45 minutes will return that amount in seconds.
|
||||
*/
|
||||
export function getTimestampOffset(timestamp: number) {
|
||||
return (getUTCOffset(new Date(timestamp * 1000)) % 60) * 60;
|
||||
}
|
||||
|
||||
export function getRangeForTimestamp(timestamp: number) {
|
||||
const date = new Date(timestamp * 1000);
|
||||
date.setMinutes(0, 0, 0);
|
||||
@@ -301,9 +292,7 @@ export function getEndOfDayTimestamp(date: Date) {
|
||||
|
||||
export function isCurrentHour(timestamp: number) {
|
||||
const now = new Date();
|
||||
now.setMinutes(0, 0, 0);
|
||||
now.setUTCMinutes(0, 0, 0);
|
||||
|
||||
const timeShift = getTimestampOffset(timestamp);
|
||||
|
||||
return timestamp + timeShift > now.getTime() / 1000;
|
||||
return timestamp > now.getTime() / 1000;
|
||||
}
|
||||
|
||||
@@ -131,13 +131,12 @@ export function getChunkedTimeDay(timeRange: TimeRange): TimeRange[] {
|
||||
endOfThisHour.setSeconds(0, 0);
|
||||
const data: TimeRange[] = [];
|
||||
const startDay = new Date(timeRange.after * 1000);
|
||||
startDay.setMinutes(0, 0, 0);
|
||||
|
||||
startDay.setUTCMinutes(0, 0, 0);
|
||||
let start = startDay.getTime() / 1000;
|
||||
let end = 0;
|
||||
|
||||
for (let i = 0; i < 24; i++) {
|
||||
startDay.setHours(startDay.getHours() + 1, 0, 0, 0);
|
||||
startDay.setHours(startDay.getHours() + 1);
|
||||
|
||||
if (startDay > endOfThisHour) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user