Rocky_Mountain_Vending/.pnpm-store/v10/files/e6/9597b4ac5a4550fd8fa3149057b43e2d6e7ee980fe51310e4dc50da4e0f9631dd90ea04868d865013c18b7019736662fc2e3cd5e13da098cc5c95910933b86
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

44 lines
No EOL
1.5 KiB
Text

"use strict";
exports.tzOffset = tzOffset;
const offsetFormatCache = {};
const offsetCache = {};
/**
* The function extracts UTC offset in minutes from the given date in specified
* time zone.
*
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param date - Date to check the offset for
*
* @returns UTC offset in minutes
*/
function tzOffset(timeZone, date) {
try {
const format = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat("en-GB", {
timeZone,
hour: "numeric",
timeZoneName: "longOffset"
}).format;
const offsetStr = format(date).split('GMT')[1] || '';
if (offsetStr in offsetCache) return offsetCache[offsetStr];
return calcOffset(offsetStr, offsetStr.split(":"));
} catch {
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
// See: https://github.com/nodejs/node/issues/53419
if (timeZone in offsetCache) return offsetCache[timeZone];
const captures = timeZone?.match(offsetRe);
if (captures) return calcOffset(timeZone, captures.slice(1));
return NaN;
}
}
const offsetRe = /([+-]\d\d):?(\d\d)?/;
function calcOffset(cacheStr, values) {
const hours = +values[0];
const minutes = +(values[1] || 0);
return offsetCache[cacheStr] = hours > 0 ? hours * 60 + minutes : hours * 60 - minutes;
}