Rocky_Mountain_Vending/.pnpm-store/v10/files/4e/9cf3477153cf3d0069ff3395e874272e40162dc69371d1b937b81960cd90dd51745bd8cd7b4c916d4421ee9d1954460c9433aa1f80024407e1e5601a911f80
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

73 lines
No EOL
2.3 KiB
Text

import { tzOffset } from "../tzOffset/index.js";
/**
* Time interval.
*/
/**
* Time zone change record.
*/
/**
* The function scans the time zone for changes in the given interval.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param interval - Time interval to scan for changes
*
* @returns Array of time zone changes
*/
export function tzScan(timeZone, interval) {
const changes = [];
const monthDate = new Date(interval.start);
monthDate.setUTCSeconds(0, 0);
const endDate = new Date(interval.end);
endDate.setUTCSeconds(0, 0);
const endMonthTime = +endDate;
let lastOffset = tzOffset(timeZone, monthDate);
while (+monthDate < endMonthTime) {
// Month forward
monthDate.setUTCMonth(monthDate.getUTCMonth() + 1);
// Find the month where the offset changes
const offset = tzOffset(timeZone, monthDate);
if (offset != lastOffset) {
// Rewind a month back to find the day where the offset changes
const dayDate = new Date(monthDate);
dayDate.setUTCMonth(dayDate.getUTCMonth() - 1);
const endDayTime = +monthDate;
lastOffset = tzOffset(timeZone, dayDate);
while (+dayDate < endDayTime) {
// Day forward
dayDate.setUTCDate(dayDate.getUTCDate() + 1);
// Find the day where the offset changes
const offset = tzOffset(timeZone, dayDate);
if (offset != lastOffset) {
// Rewind a day back to find the time where the offset changes
const hourDate = new Date(dayDate);
hourDate.setUTCDate(hourDate.getUTCDate() - 1);
const endHourTime = +dayDate;
lastOffset = tzOffset(timeZone, hourDate);
while (+hourDate < endHourTime) {
// Hour forward
hourDate.setUTCHours(hourDate.getUTCHours() + 1);
// Find the hour where the offset changes
const hourOffset = tzOffset(timeZone, hourDate);
if (hourOffset !== lastOffset) {
changes.push({
date: new Date(hourDate),
change: hourOffset - lastOffset,
offset: hourOffset
});
}
lastOffset = hourOffset;
}
}
lastOffset = offset;
}
}
lastOffset = offset;
}
return changes;
}