@adyen/adyen-platform-experience-web
Version:

59 lines (58 loc) • 2.41 kB
JavaScript
import { BASE_FORMAT_OPTIONS as p, BASE_LOCALE as u } from "../../../../core/Localization/datetime/restamper/constants.js";
import { DEFAULT_DATETIME_FORMAT as f } from "../../../../core/Localization/constants/localization.js";
import { timezoneToSystem as O, systemToTimezone as E } from "../../../../core/Localization/datetime/restamper/utils.js";
import M from "../../../../core/Localization/datetime/restamper/restamper.js";
import { isInfinity as m, mod as g } from "../../../../utils/value/number.js";
import { identity as A } from "../../../../utils/common.js";
import { EMPTY_OBJECT as _, EMPTY_ARRAY 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, o, ...n) => {
const s = d(o), r = new Date(O(s, e));
return r.setHours(0, 0, 0, 0), E(s, t(r, ...n));
}, z = c(), C = c((t) => t.setDate(1)), U = c((t) => t.setMonth(0, 1)), W = c((t, e) => {
const o = R(t.getDay(), e ?? 0);
return t.setDate(t.getDate() - o);
}), I = (t) => (t % 100 ? t % 4 : t % 400) === 0, Z = (t, e, o = 0) => {
const n = t + o, s = g(n, 12), r = e + Math.floor(n / 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), v = (t) => S(t) ? t : new Date(t), w = (t, e = _) => {
const o = d(e.timeZone), n = { ...f, ...e, timeZone: o.tz.current };
return new Date(t).toLocaleDateString(u, n);
}, i = (t, e) => {
const o = w(t, { ...p, ...f, timeZone: e, hour12: !1 }), [, n = "", s = "", r = "", a = "", D = "", T = "", h = ""] = o.match(Y) ?? y;
return [+r, +n - 1, +s, +a % 24, +D, +T, +h];
}, G = (t, e, o) => {
if (m(t) || m(e)) return 1 / 0;
const [n, s] = i(t, o), [r, a] = i(e, o);
return Math.abs(a - s + (r - n) * 12);
}, d = (() => {
const t = M();
return (e) => (t.tz = void 0, t.tz = e, t);
})();
export {
j as computeTimestampOffset,
v as getDateObjectFromTimestamp,
G 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
};