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)

59 lines (58 loc) 2.41 kB
import { BASE_FORMAT_OPTIONS as h, BASE_LOCALE as p } from "../../../../core/Localization/datetime/restamper/constants.js"; import { DEFAULT_DATETIME_FORMAT as f } from "../../../../core/Localization/constants/localization.js"; import O from "../../../../core/Localization/datetime/restamper/restamper.js"; import { timezoneToSystem as E, systemToTimezone as M } from "../../../../core/Localization/datetime/restamper/utils.js"; import { isInfinity as m, mod as g } from "../../../../utils/value/number.js"; import { identity as A } from "../../../../utils/common.js"; import { EMPTY_ARRAY as _, EMPTY_OBJECT as y } from "../../../../utils/value/constants.js"; import { isUndefined as S } from "../../../../utils/value/is.js"; const Y = /^(\d{2})\/(\d{2})\/(-?\d+),\s+(\d{2}):(\d{2}):(\d{2}).(\d{3})/, c = (t = A) => (e, n, ...o) => { const s = d(n), r = new Date(E(s, e)); return r.setHours(0, 0, 0, 0), M(s, t(r, ...o)); }, z = c(), C = c((t) => t.setDate(1)), U = c((t) => t.setMonth(0, 1)), W = c((t, e) => { const n = R(t.getDay(), e ?? 0); return t.setDate(t.getDate() - n); }), I = (t) => (t % 100 ? t % 4 : t % 400) === 0, Z = (t, e, n = 0) => { const o = t + n, s = g(o, 12), r = e + Math.floor(o / 12); let a = 31; switch (s) { case 1: a = I(r) ? 29 : 28; break; case 3: case 5: case 8: case 10: a = 30; break; } return [a, s, r]; }, R = (t, e = 0) => (7 - e + t) % 7, j = (t, e) => m(t) ? 0 : t - z(t, e), G = (t) => S(t) ? t : new Date(t), w = (t, e = y) => { const n = d(e.timeZone), o = { ...f, ...e, timeZone: n.tz.current }; return new Date(t).toLocaleDateString(p, o); }, i = (t, e) => { const n = w(t, { ...h, ...f, timeZone: e, hour12: !1 }), [, o = "", s = "", r = "", a = "", D = "", T = "", u = ""] = n.match(Y) ?? _; return [+r, +o - 1, +s, +a % 24, +D, +T, +u]; }, H = (t, e, n) => { if (m(t) || m(e)) return 1 / 0; const [o, s] = i(t, n), [r, a] = i(e, n); return Math.abs(a - s + (r - o) * 12); }, d = (() => { const t = O(); return (e) => (t.tz = void 0, t.tz = e, t); })(); export { j as computeTimestampOffset, G as getDateObjectFromTimestamp, H as getEdgesDistance, Z as getMonthDays, i as getTimezoneDateParts, w as getTimezoneDateString, R as getWeekDayIndex, I as isLeapYear, z as startOfDay, C as startOfMonth, W as startOfWeek, U as startOfYear, d as withTimezone };