UNPKG

laif-ds

Version:

Design System di Laif con componenti React basati su principi di Atomic Design

25 lines (24 loc) 566 B
"use client"; const e = {}, f = {}; function a(t, c) { try { const n = (e[t] ||= new Intl.DateTimeFormat("en-GB", { timeZone: t, hour: "numeric", timeZoneName: "longOffset" }).format)(c).split("GMT")[1] || ""; return n in f ? f[n] : s(n, n.split(":")); } catch { if (t in f) return f[t]; const r = t?.match(o); return r ? s(t, r.slice(1)) : NaN; } } const o = /([+-]\d\d):?(\d\d)?/; function s(t, c) { const r = +c[0], n = +(c[1] || 0); return f[t] = r > 0 ? r * 60 + n : r * 60 - n; } export { a as tzOffset };