UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

42 lines (41 loc) 1.35 kB
import { SYSTEM_TIMEZONE as s, SYSTEM_TIMEZONE_FORMATTER as f, BASE_LOCALE as c, BASE_FORMAT_OPTIONS as E } from "./constants.js"; import { getTimezoneOffsetForTimestamp as a } from "./utils.js"; import { struct as O } from "../../../../utils/struct/main.js"; import { isUndefined as T, isNullish as u } from "../../../../utils/value/is.js"; const d = (() => { let n, i; T(s) || (n = function() { return this.TIMEZONE; }, i = function(t) { if (u(t)) this.TIMEZONE = s, this.formatter = f; else try { const e = new Intl.DateTimeFormat(c, { ...E, timeZone: t }), r = e.resolvedOptions().timeZone; if (this.TIMEZONE === r) return; this.TIMEZONE = r, this.formatter = e; } catch { } }); function m(...t) { if (t.length === 0) return m.call(this, Date.now()); const e = t[0], r = new Date(e).getTime(), o = this.formatter ?? f; return Object.freeze({ formatted: o == null ? void 0 : o.format(r), offset: a(r, o), timestamp: r }); } return () => { const t = { TIMEZONE: s }, e = i == null ? void 0 : i.bind(t), r = O({ current: { get: n == null ? void 0 : n.bind(t), set: e }, system: { value: s } }); return Object.defineProperties(m.bind(t), { tz: { get: () => r, set: e } }); }; })(); export { d as default };