esday 0.5.0 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/LICENSE +21 -21
- package/README.md +63 -51
- package/chunks/AyQQ6US-.js +84 -0
- package/chunks/{Y32qdU_5.js → BkjWOpMU.js} +7 -1
- package/chunks/{MtjcOKi-.d.ts → C5qDMHT5.d.ts} +2 -2
- package/chunks/{DqhiVwLi.d.ts → CODi8AFH.d.ts} +63 -35
- package/chunks/CXWzCl3n.js +481 -0
- package/chunks/{BRRrAbUl.js → CdvTtmWL.js} +2 -2
- package/chunks/{DXHbH1CI.js → Shk32pTP.js} +1 -1
- package/chunks/{Cb5SvF6r.js → v_QBn7Xm.js} +1 -1
- package/chunks/xt8C2lbv.js +38 -0
- package/index.d.ts +3 -3
- package/index.js +1 -571
- package/locales/af.d.ts +1 -3
- package/locales/af.js +4 -2
- package/locales/am.d.ts +1 -3
- package/locales/am.js +4 -2
- package/locales/ar-dz.d.ts +1 -3
- package/locales/ar-dz.js +7 -9
- package/locales/ar-iq.d.ts +1 -3
- package/locales/ar-iq.js +7 -9
- package/locales/ar-kw.d.ts +1 -3
- package/locales/ar-kw.js +7 -9
- package/locales/ar-ly.d.ts +1 -3
- package/locales/ar-ly.js +7 -9
- package/locales/ar-ma.d.ts +1 -3
- package/locales/ar-ma.js +7 -9
- package/locales/ar-sa.d.ts +1 -3
- package/locales/ar-sa.js +7 -9
- package/locales/ar-tn.d.ts +1 -3
- package/locales/ar-tn.js +7 -9
- package/locales/ar.d.ts +1 -3
- package/locales/ar.js +197 -2
- package/locales/az.d.ts +1 -3
- package/locales/az.js +4 -2
- package/locales/be.d.ts +1 -3
- package/locales/be.js +55 -59
- package/locales/bg.d.ts +1 -3
- package/locales/bg.js +4 -2
- package/locales/bi.d.ts +1 -3
- package/locales/bi.js +4 -2
- package/locales/bm.d.ts +1 -3
- package/locales/bm.js +4 -2
- package/locales/bn-bd.d.ts +1 -3
- package/locales/bn-bd.js +7 -9
- package/locales/bn.d.ts +1 -3
- package/locales/bn.js +136 -2
- package/locales/bo.d.ts +1 -3
- package/locales/bo.js +4 -2
- package/locales/br.d.ts +1 -3
- package/locales/br.js +10 -9
- package/locales/bs.d.ts +1 -3
- package/locales/bs.js +4 -2
- package/locales/ca.d.ts +1 -3
- package/locales/ca.js +35 -36
- package/locales/cs.d.ts +1 -3
- package/locales/cs.js +38 -34
- package/locales/cv.d.ts +1 -3
- package/locales/cv.js +4 -2
- package/locales/cy.d.ts +1 -3
- package/locales/cy.js +4 -2
- package/locales/da.d.ts +1 -3
- package/locales/da.js +4 -2
- package/locales/de-at.d.ts +1 -3
- package/locales/de-at.js +7 -9
- package/locales/de-ch.d.ts +1 -3
- package/locales/de-ch.js +7 -9
- package/locales/de.d.ts +1 -3
- package/locales/de.js +130 -2
- package/locales/dv.d.ts +1 -3
- package/locales/dv.js +4 -2
- package/locales/el.d.ts +1 -3
- package/locales/el.js +4 -2
- package/locales/en-au.d.ts +1 -3
- package/locales/en-au.js +7 -8
- package/locales/en-ca.d.ts +1 -3
- package/locales/en-ca.js +7 -8
- package/locales/en-gb.d.ts +1 -3
- package/locales/en-gb.js +9 -8
- package/locales/en-ie.d.ts +1 -3
- package/locales/en-ie.js +7 -8
- package/locales/en-il.d.ts +1 -3
- package/locales/en-il.js +7 -8
- package/locales/en-in.d.ts +1 -3
- package/locales/en-in.js +7 -8
- package/locales/en-nz.d.ts +1 -3
- package/locales/en-nz.js +7 -8
- package/locales/en-sg.d.ts +1 -3
- package/locales/en-sg.js +7 -8
- package/locales/en-tt.d.ts +1 -3
- package/locales/en-tt.js +7 -8
- package/locales/en-us.d.ts +1 -3
- package/locales/en-us.js +7 -8
- package/locales/en.d.ts +1 -3
- package/locales/en.js +116 -2
- package/locales/eo.d.ts +1 -3
- package/locales/eo.js +4 -2
- package/locales/es-do.d.ts +1 -3
- package/locales/es-do.js +7 -9
- package/locales/es-mx.d.ts +1 -3
- package/locales/es-mx.js +7 -9
- package/locales/es-pr.d.ts +1 -3
- package/locales/es-pr.js +7 -9
- package/locales/es-us.d.ts +1 -3
- package/locales/es-us.js +7 -9
- package/locales/es.d.ts +1 -3
- package/locales/es.js +117 -2
- package/locales/et.d.ts +1 -3
- package/locales/et.js +6 -2
- package/locales/eu.d.ts +1 -3
- package/locales/eu.js +4 -2
- package/locales/fa.d.ts +1 -3
- package/locales/fa.js +4 -2
- package/locales/fi.d.ts +1 -3
- package/locales/fi.js +8 -2
- package/locales/fil.d.ts +1 -3
- package/locales/fil.js +4 -2
- package/locales/fo.d.ts +1 -3
- package/locales/fo.js +4 -2
- package/locales/fr-ca.d.ts +1 -3
- package/locales/fr-ca.js +7 -9
- package/locales/fr-ch.d.ts +1 -3
- package/locales/fr-ch.js +7 -9
- package/locales/fr.d.ts +1 -3
- package/locales/fr.js +109 -2
- package/locales/fy.d.ts +1 -3
- package/locales/fy.js +4 -2
- package/locales/ga.d.ts +1 -3
- package/locales/ga.js +4 -2
- package/locales/gd.d.ts +1 -3
- package/locales/gd.js +4 -2
- package/locales/gl.d.ts +1 -3
- package/locales/gl.js +4 -2
- package/locales/gom-deva.d.ts +1 -3
- package/locales/gom-deva.js +34 -32
- package/locales/gom-latn.d.ts +1 -3
- package/locales/gom-latn.js +34 -32
- package/locales/gu.d.ts +1 -3
- package/locales/gu.js +4 -2
- package/locales/he.d.ts +1 -3
- package/locales/he.js +8 -5
- package/locales/hi.d.ts +1 -3
- package/locales/hi.js +34 -35
- package/locales/hr.d.ts +1 -3
- package/locales/hr.js +10 -4
- package/locales/ht.d.ts +1 -3
- package/locales/ht.js +4 -2
- package/locales/hu.d.ts +1 -3
- package/locales/hu.js +6 -2
- package/locales/hy-am.d.ts +1 -3
- package/locales/hy-am.js +34 -35
- package/locales/id.d.ts +1 -3
- package/locales/id.js +4 -2
- package/locales/is.d.ts +1 -3
- package/locales/is.js +14 -2
- package/locales/it-ch.d.ts +1 -3
- package/locales/it-ch.js +4 -9
- package/locales/it.d.ts +1 -3
- package/locales/it.js +120 -2
- package/locales/ja.d.ts +1 -4
- package/locales/ja.js +4 -2
- package/locales/jv.d.ts +1 -3
- package/locales/jv.js +4 -2
- package/locales/ka.d.ts +1 -3
- package/locales/ka.js +25 -26
- package/locales/kk.d.ts +1 -3
- package/locales/kk.js +4 -2
- package/locales/km.d.ts +1 -3
- package/locales/km.js +4 -2
- package/locales/kn.d.ts +1 -3
- package/locales/kn.js +4 -2
- package/locales/ko.d.ts +1 -3
- package/locales/ko.js +5 -3
- package/locales/ku.d.ts +1 -3
- package/locales/ku.js +4 -2
- package/locales/ky.d.ts +1 -3
- package/locales/ky.js +4 -2
- package/locales/lb.d.ts +1 -3
- package/locales/lb.js +5 -2
- package/locales/lo.d.ts +1 -3
- package/locales/lo.js +4 -2
- package/locales/lt.d.ts +1 -3
- package/locales/lt.js +4 -2
- package/locales/lv.d.ts +1 -3
- package/locales/lv.js +4 -2
- package/locales/me.d.ts +1 -3
- package/locales/me.js +33 -33
- package/locales/mi.d.ts +1 -3
- package/locales/mi.js +4 -2
- package/locales/mk.d.ts +1 -3
- package/locales/mk.js +4 -2
- package/locales/ml.d.ts +1 -3
- package/locales/ml.js +4 -2
- package/locales/mn.d.ts +1 -3
- package/locales/mn.js +37 -16
- package/locales/mr.d.ts +1 -3
- package/locales/mr.js +16 -2
- package/locales/ms-my.d.ts +1 -3
- package/locales/ms-my.js +7 -9
- package/locales/ms.d.ts +1 -3
- package/locales/ms.js +107 -2
- package/locales/mt.d.ts +1 -3
- package/locales/mt.js +4 -2
- package/locales/my.d.ts +1 -3
- package/locales/my.js +4 -2
- package/locales/nb.d.ts +1 -3
- package/locales/nb.js +4 -2
- package/locales/ne.d.ts +1 -3
- package/locales/ne.js +4 -2
- package/locales/nl-be.d.ts +1 -3
- package/locales/nl-be.js +7 -9
- package/locales/nl.d.ts +1 -3
- package/locales/nl.js +107 -2
- package/locales/nn.d.ts +1 -3
- package/locales/nn.js +4 -2
- package/locales/oc-lnc.d.ts +1 -3
- package/locales/oc-lnc.js +35 -36
- package/locales/pa-in.d.ts +1 -3
- package/locales/pa-in.js +4 -2
- package/locales/pl.d.ts +1 -3
- package/locales/pl.js +5 -2
- package/locales/pt-br.d.ts +1 -3
- package/locales/pt-br.js +7 -9
- package/locales/pt.d.ts +1 -3
- package/locales/pt.js +109 -2
- package/locales/rn.d.ts +1 -3
- package/locales/rn.js +4 -2
- package/locales/ro.d.ts +1 -3
- package/locales/ro.js +4 -2
- package/locales/ru.d.ts +1 -4
- package/locales/ru.js +83 -82
- package/locales/rw.d.ts +1 -3
- package/locales/rw.js +4 -2
- package/locales/sd.d.ts +1 -3
- package/locales/sd.js +4 -2
- package/locales/se.d.ts +1 -3
- package/locales/se.js +4 -2
- package/locales/si.d.ts +1 -3
- package/locales/si.js +4 -2
- package/locales/sk.d.ts +1 -3
- package/locales/sk.js +8 -2
- package/locales/sl.d.ts +1 -3
- package/locales/sl.js +8 -2
- package/locales/sq.d.ts +1 -3
- package/locales/sq.js +4 -2
- package/locales/sr-cyrl.d.ts +1 -3
- package/locales/sr-cyrl.js +16 -15
- package/locales/sr.d.ts +1 -3
- package/locales/sr.js +185 -2
- package/locales/ss.d.ts +1 -3
- package/locales/ss.js +4 -2
- package/locales/sv-fi.d.ts +1 -3
- package/locales/sv-fi.js +7 -9
- package/locales/sv.d.ts +1 -3
- package/locales/sv.js +110 -2
- package/locales/sw.d.ts +1 -3
- package/locales/sw.js +4 -2
- package/locales/ta.d.ts +1 -3
- package/locales/ta.js +4 -2
- package/locales/te.d.ts +1 -3
- package/locales/te.js +4 -2
- package/locales/tet.d.ts +1 -3
- package/locales/tet.js +5 -4
- package/locales/tg.d.ts +1 -3
- package/locales/tg.js +34 -35
- package/locales/th.d.ts +1 -3
- package/locales/th.js +4 -2
- package/locales/tk.d.ts +1 -3
- package/locales/tk.js +5 -4
- package/locales/tl-ph.d.ts +1 -3
- package/locales/tl-ph.js +4 -2
- package/locales/tlh.d.ts +1 -3
- package/locales/tlh.js +5 -2
- package/locales/tr.d.ts +1 -3
- package/locales/tr.js +5 -4
- package/locales/tzl.d.ts +1 -3
- package/locales/tzl.js +4 -2
- package/locales/tzm-latn.d.ts +1 -3
- package/locales/tzm-latn.js +9 -9
- package/locales/tzm.d.ts +1 -3
- package/locales/tzm.js +107 -2
- package/locales/ug-cn.d.ts +1 -3
- package/locales/ug-cn.js +4 -2
- package/locales/uk.d.ts +1 -3
- package/locales/uk.js +37 -32
- package/locales/ur.d.ts +1 -3
- package/locales/ur.js +4 -2
- package/locales/uz-latn.d.ts +1 -3
- package/locales/uz-latn.js +9 -9
- package/locales/uz.d.ts +1 -3
- package/locales/uz.js +107 -2
- package/locales/vi.d.ts +1 -3
- package/locales/vi.js +4 -2
- package/locales/x-pseudo.d.ts +1 -3
- package/locales/x-pseudo.js +5 -4
- package/locales/yo.d.ts +1 -3
- package/locales/yo.js +4 -2
- package/locales/zh-cn.d.ts +1 -3
- package/locales/zh-cn.js +7 -9
- package/locales/zh-hk.d.ts +1 -3
- package/locales/zh-hk.js +7 -9
- package/locales/zh-mo.d.ts +1 -3
- package/locales/zh-mo.js +7 -9
- package/locales/zh-tw.d.ts +1 -3
- package/locales/zh-tw.js +7 -9
- package/locales/zh.d.ts +1 -4
- package/locales/zh.js +128 -2
- package/package.json +29 -23
- package/plugins/advancedFormat/index.d.ts +1 -3
- package/plugins/advancedFormat/index.js +4 -6
- package/plugins/advancedParse/index.d.ts +1 -3
- package/plugins/advancedParse/index.js +21 -20
- package/plugins/calendar/index.d.ts +2 -4
- package/plugins/calendar/index.js +1 -2
- package/plugins/dayOfYear/index.d.ts +1 -2
- package/plugins/dayOfYear/index.js +1 -2
- package/plugins/duration/index.d.ts +78 -0
- package/plugins/duration/index.js +477 -0
- package/plugins/isBetween/index.d.ts +1 -2
- package/plugins/isBetween/index.js +2 -3
- package/plugins/isLeapYear/index.d.ts +1 -2
- package/plugins/isLeapYear/index.js +1 -2
- package/plugins/isSameOrAfter/index.d.ts +1 -2
- package/plugins/isSameOrAfter/index.js +1 -2
- package/plugins/isSameOrBefore/index.d.ts +1 -2
- package/plugins/isSameOrBefore/index.js +1 -2
- package/plugins/isToday/index.d.ts +1 -2
- package/plugins/isToday/index.js +2 -3
- package/plugins/isTomorrow/index.d.ts +1 -2
- package/plugins/isTomorrow/index.js +2 -3
- package/plugins/isYesterday/index.d.ts +1 -2
- package/plugins/isYesterday/index.js +2 -3
- package/plugins/isoWeek/index.d.ts +1 -3
- package/plugins/isoWeek/index.js +13 -25
- package/plugins/locale/index.d.ts +103 -3
- package/plugins/locale/index.js +140 -6
- package/plugins/localeData/index.d.ts +1 -3
- package/plugins/localeData/index.js +18 -11
- package/plugins/localizedFormat/index.d.ts +1 -3
- package/plugins/localizedFormat/index.js +5 -10
- package/plugins/localizedParse/index.d.ts +1 -3
- package/plugins/localizedParse/index.js +40 -22
- package/plugins/minMax/index.d.ts +1 -2
- package/plugins/minMax/index.js +2 -3
- package/plugins/objectSupport/index.d.ts +1 -3
- package/plugins/objectSupport/index.js +33 -38
- package/plugins/pluralGetSet/index.d.ts +1 -3
- package/plugins/pluralGetSet/index.js +1 -2
- package/plugins/quarterOfYear/index.d.ts +1 -3
- package/plugins/quarterOfYear/index.js +11 -18
- package/plugins/relativeTime/index.d.ts +32 -44
- package/plugins/relativeTime/index.js +124 -91
- package/plugins/timezone/index.d.ts +6 -0
- package/plugins/timezone/index.js +456 -0
- package/plugins/toArray/index.d.ts +1 -2
- package/plugins/toArray/index.js +1 -2
- package/plugins/toObject/index.d.ts +1 -2
- package/plugins/toObject/index.js +1 -2
- package/plugins/utc/index.d.ts +1 -2
- package/plugins/utc/index.js +37 -39
- package/plugins/week/index.d.ts +1 -3
- package/plugins/week/index.js +17 -27
- package/chunks/B5f9poqo.js +0 -120
- package/chunks/BDssPbM_.js +0 -106
- package/chunks/BXRGSAJG.js +0 -128
- package/chunks/BeVgU2nj.js +0 -188
- package/chunks/BtmEtAW3.js +0 -43
- package/chunks/CQ57zhVp.js +0 -106
- package/chunks/CQJ0-ZuR.js +0 -106
- package/chunks/CWqzr5E5.js +0 -108
- package/chunks/Cg4ZI9v8.js +0 -180
- package/chunks/CoBtJ4c1.js +0 -144
- package/chunks/D009Z-ld.js +0 -109
- package/chunks/DMtTiWuY.js +0 -127
- package/chunks/Dixb5KKs.js +0 -116
- package/chunks/DjY7KvwG.js +0 -28
- package/chunks/GjKpN6U-.js +0 -135
- package/chunks/St35qgL0.d.ts +0 -103
- package/chunks/br7kModF.js +0 -110
- package/chunks/l2Rxo2H0.js +0 -106
- package/chunks/tfkJ5D3p.js +0 -115
package/index.js
CHANGED
|
@@ -1,573 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isArray, isEmptyObject, isObject, isUndefined, isValidDate } from "./chunks/Cb5SvF6r.js";
|
|
3
|
-
import { normalizeUnit, normalizeUnitWithPlurals } from "./chunks/DjY7KvwG.js";
|
|
4
|
-
import { getUnitInDate, prettyUnitsDate, setUnitInDate } from "./chunks/BtmEtAW3.js";
|
|
5
|
-
import { createInstanceFromExist } from "./chunks/DXHbH1CI.js";
|
|
6
|
-
import { padStart, padZoneStr } from "./chunks/BRRrAbUl.js";
|
|
1
|
+
import { n as EsDay, t as esday } from "./chunks/CXWzCl3n.js";
|
|
7
2
|
|
|
8
|
-
//#region rolldown:runtime
|
|
9
|
-
var __create = Object.create;
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
14
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var __commonJS = (cb, mod) => function() {
|
|
16
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
-
key = keys[i];
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
-
get: ((k) => from[k]).bind(null, key),
|
|
23
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
-
value: mod,
|
|
30
|
-
enumerable: true
|
|
31
|
-
}) : target, mod));
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/core/Impl/add.ts
|
|
35
|
-
function addImpl(that, value, units) {
|
|
36
|
-
const $d = that["$d"];
|
|
37
|
-
const unit = normalizeUnitWithPlurals(units);
|
|
38
|
-
const instanceFactorySet = (multiplier) => {
|
|
39
|
-
const newInstance = that.clone();
|
|
40
|
-
newInstance["$d"].setDate($d.getDate() + Math.round(multiplier * value));
|
|
41
|
-
return newInstance;
|
|
42
|
-
};
|
|
43
|
-
switch (normalizeUnitWithPlurals(unit)) {
|
|
44
|
-
case constants_default.YEAR: return that.set("year", that.get("year") + value);
|
|
45
|
-
case constants_default.MONTH: return that.set("month", that.get("month") + value);
|
|
46
|
-
case constants_default.WEEK: return instanceFactorySet(7);
|
|
47
|
-
case constants_default.DAY:
|
|
48
|
-
case constants_default.DAY_OF_MONTH: return instanceFactorySet(1);
|
|
49
|
-
case constants_default.HOUR:
|
|
50
|
-
case constants_default.MIN:
|
|
51
|
-
case constants_default.SECOND:
|
|
52
|
-
case constants_default.MS: {
|
|
53
|
-
const step = {
|
|
54
|
-
minute: 60 * 1e3,
|
|
55
|
-
hour: 3600 * 1e3,
|
|
56
|
-
second: 1e3
|
|
57
|
-
}[unit] || 1;
|
|
58
|
-
const nextTimeStamp = $d.getTime() + value * step;
|
|
59
|
-
return createInstanceFromExist(new Date(nextTimeStamp), that);
|
|
60
|
-
}
|
|
61
|
-
default: return that.clone();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/core/Impl/diff.ts
|
|
67
|
-
/**
|
|
68
|
-
* get difference between 2 dates as months.
|
|
69
|
-
* As implemented by moment.js, the algorithm is optimized to ensure that two months
|
|
70
|
-
* with the same date are always a whole number apart.
|
|
71
|
-
* @param a - date 1
|
|
72
|
-
* @param b - date 2
|
|
73
|
-
* @returns b - a in months
|
|
74
|
-
*/
|
|
75
|
-
function monthDiff(a, b) {
|
|
76
|
-
if (a.date() < b.date()) return -monthDiff(b, a);
|
|
77
|
-
const wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
|
|
78
|
-
const anchor = a.clone().add(wholeMonthDiff, constants_default.MONTH);
|
|
79
|
-
const c = b.valueOf() - anchor.valueOf() < 0;
|
|
80
|
-
const anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), constants_default.MONTH);
|
|
81
|
-
return +(-(wholeMonthDiff + (b.valueOf() - anchor.valueOf()) / (c ? anchor.valueOf() - anchor2.valueOf() : anchor2.valueOf() - anchor.valueOf())) || 0);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Drop fractional part of a number.
|
|
85
|
-
* @param n - number to inspect
|
|
86
|
-
* @returns n without fractional part
|
|
87
|
-
*/
|
|
88
|
-
function absFloor(n) {
|
|
89
|
-
return n < 0 ? Math.ceil(n) : Math.floor(n);
|
|
90
|
-
}
|
|
91
|
-
function diffImpl(that, date, units, asFloat = false) {
|
|
92
|
-
const diffInMs = that.valueOf() - date.valueOf();
|
|
93
|
-
const diffInMonths = monthDiff(that, date);
|
|
94
|
-
const zoneDelta = (that.utcOffset() - date.utcOffset()) * constants_default.MILLISECONDS_A_MINUTE;
|
|
95
|
-
let result;
|
|
96
|
-
if (isUndefined(units)) result = diffInMs;
|
|
97
|
-
else {
|
|
98
|
-
const unit = normalizeUnitWithPlurals(units);
|
|
99
|
-
switch (unit) {
|
|
100
|
-
case constants_default.YEAR:
|
|
101
|
-
result = diffInMonths / 12;
|
|
102
|
-
break;
|
|
103
|
-
case constants_default.MONTH:
|
|
104
|
-
result = diffInMonths;
|
|
105
|
-
break;
|
|
106
|
-
case constants_default.QUARTER:
|
|
107
|
-
result = diffInMonths / 3;
|
|
108
|
-
break;
|
|
109
|
-
case constants_default.WEEK:
|
|
110
|
-
result = (diffInMs + zoneDelta) / constants_default.MILLISECONDS_A_WEEK;
|
|
111
|
-
break;
|
|
112
|
-
case constants_default.DAY:
|
|
113
|
-
result = (diffInMs + zoneDelta) / constants_default.MILLISECONDS_A_DAY;
|
|
114
|
-
break;
|
|
115
|
-
case constants_default.HOUR:
|
|
116
|
-
result = diffInMs / constants_default.MILLISECONDS_A_HOUR;
|
|
117
|
-
break;
|
|
118
|
-
case constants_default.MIN:
|
|
119
|
-
result = diffInMs / constants_default.MILLISECONDS_A_MINUTE;
|
|
120
|
-
break;
|
|
121
|
-
case constants_default.SECOND:
|
|
122
|
-
result = diffInMs / constants_default.MILLISECONDS_A_SECOND;
|
|
123
|
-
break;
|
|
124
|
-
default:
|
|
125
|
-
result = diffInMs;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return asFloat ? result : absFloor(result);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/core/Impl/format.ts
|
|
134
|
-
const formattingSeparatorsRegex = "\\[([^\\]]+)\\]";
|
|
135
|
-
let formattingTokensRegex;
|
|
136
|
-
const formatTokensDefinitions = {
|
|
137
|
-
YY: (sourceDate) => padStart(sourceDate.year(), 2, "0").slice(-2),
|
|
138
|
-
YYYY: (sourceDate) => padStart(sourceDate.year(), 4, "0"),
|
|
139
|
-
M: (sourceDate) => String(sourceDate.month() + 1),
|
|
140
|
-
MM: (sourceDate) => padStart(sourceDate.month() + 1, 2, "0"),
|
|
141
|
-
D: (sourceDate) => String(sourceDate.date()),
|
|
142
|
-
DD: (sourceDate) => padStart(sourceDate.date(), 2, "0"),
|
|
143
|
-
H: (sourceDate) => String(sourceDate.hour()),
|
|
144
|
-
HH: (sourceDate) => padStart(sourceDate.hour(), 2, "0"),
|
|
145
|
-
m: (sourceDate) => String(sourceDate.minute()),
|
|
146
|
-
mm: (sourceDate) => padStart(sourceDate.minute(), 2, "0"),
|
|
147
|
-
s: (sourceDate) => String(sourceDate.second()),
|
|
148
|
-
ss: (sourceDate) => padStart(sourceDate.second(), 2, "0"),
|
|
149
|
-
SSS: (sourceDate) => padStart(sourceDate.millisecond(), 3, "0"),
|
|
150
|
-
Z: (sourceDate) => padZoneStr(sourceDate.utcOffset())
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Compare 2 tokens for sorting.
|
|
154
|
-
* Longer token and upper case token are sorted to the top.
|
|
155
|
-
* As we sort here object keys, a and b can never be equal.
|
|
156
|
-
* @param a - token 1
|
|
157
|
-
* @param b - token 2
|
|
158
|
-
* @returns -1 (a<b), 0 (a==b), 1 (a>b)
|
|
159
|
-
*/
|
|
160
|
-
function compareTokens(a, b) {
|
|
161
|
-
if (a.length < b.length) return 1;
|
|
162
|
-
if (a.length > b.length) return -1;
|
|
163
|
-
if (a < b) return 1;
|
|
164
|
-
return -1;
|
|
165
|
-
}
|
|
166
|
-
function formattingTokensRegexFromDefinitions() {
|
|
167
|
-
const tokenKeys = Object.keys(formatTokensDefinitions).sort(compareTokens);
|
|
168
|
-
formattingTokensRegex = new RegExp(`${formattingSeparatorsRegex}|${tokenKeys.join("|")}`, "g");
|
|
169
|
-
}
|
|
170
|
-
formattingTokensRegexFromDefinitions();
|
|
171
|
-
/**
|
|
172
|
-
* Add formatting tokens to list of global formatting tokens.
|
|
173
|
-
* @param newTokens - list of new parsing token definitions
|
|
174
|
-
*/
|
|
175
|
-
function addFormatTokenDefinitions(newTokens) {
|
|
176
|
-
for (const key in newTokens) if (!Object.prototype.hasOwnProperty.call(formatTokensDefinitions, key)) formatTokensDefinitions[key] = newTokens[key];
|
|
177
|
-
formattingTokensRegexFromDefinitions();
|
|
178
|
-
}
|
|
179
|
-
function formatImpl(that, formatStr) {
|
|
180
|
-
if (!that.isValid()) return constants_default.INVALID_DATE_STRING;
|
|
181
|
-
const activeFormatString = formatStr || constants_default.FORMAT_DEFAULT;
|
|
182
|
-
const matches = (match) => {
|
|
183
|
-
const formatter = formatTokensDefinitions[match];
|
|
184
|
-
return formatter(that, formatStr);
|
|
185
|
-
};
|
|
186
|
-
return activeFormatString.replace(formattingTokensRegex, (match, $1) => $1 || matches(match));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/core/Impl/parse.ts
|
|
191
|
-
/**
|
|
192
|
-
* Create a Date object from an array of date components (year, month, ...).
|
|
193
|
-
* The month is 0 based (0..11).
|
|
194
|
-
* @param this - context to access the right function 'dateFromDateComponents'
|
|
195
|
-
* @param dateArray - array with date components (y, M, D, h, m, s ms)
|
|
196
|
-
* @returns Date object created from given array elements
|
|
197
|
-
*/
|
|
198
|
-
function parseArrayToDate(dateArray) {
|
|
199
|
-
const dateArrayTuple = [
|
|
200
|
-
0,
|
|
201
|
-
1,
|
|
202
|
-
1,
|
|
203
|
-
0,
|
|
204
|
-
0,
|
|
205
|
-
0,
|
|
206
|
-
0
|
|
207
|
-
];
|
|
208
|
-
dateArray.forEach((value, index) => {
|
|
209
|
-
if (value !== void 0) dateArrayTuple[index] = index !== 1 ? value : value + 1;
|
|
210
|
-
});
|
|
211
|
-
return this.dateFromDateComponents(...dateArrayTuple);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region src/core/Impl/startOf.ts
|
|
216
|
-
function startOfImpl(that, unit, reverse = false) {
|
|
217
|
-
const result = that.clone();
|
|
218
|
-
const setterFunc = result["$set"];
|
|
219
|
-
const instanceFactorySet = (method, slice) => {
|
|
220
|
-
const argumentStart = [
|
|
221
|
-
0,
|
|
222
|
-
0,
|
|
223
|
-
0,
|
|
224
|
-
0
|
|
225
|
-
];
|
|
226
|
-
const argumentEnd = [
|
|
227
|
-
23,
|
|
228
|
-
59,
|
|
229
|
-
59,
|
|
230
|
-
999
|
|
231
|
-
];
|
|
232
|
-
const argument = reverse ? argumentEnd.slice(slice) : argumentStart.slice(slice);
|
|
233
|
-
setterFunc.call(result, method, argument);
|
|
234
|
-
};
|
|
235
|
-
const instanceFactory = (date, month) => {
|
|
236
|
-
setterFunc.call(result, constants_default.MONTH, [month, date]);
|
|
237
|
-
};
|
|
238
|
-
const $month = result.month();
|
|
239
|
-
switch (normalizeUnit(unit)) {
|
|
240
|
-
case constants_default.YEAR:
|
|
241
|
-
reverse ? instanceFactory(31, 11) : instanceFactory(1, 0);
|
|
242
|
-
instanceFactorySet(constants_default.HOUR, 0);
|
|
243
|
-
break;
|
|
244
|
-
case constants_default.MONTH:
|
|
245
|
-
reverse ? instanceFactory(0, $month + 1) : instanceFactory(1, $month);
|
|
246
|
-
instanceFactorySet(constants_default.HOUR, 0);
|
|
247
|
-
break;
|
|
248
|
-
case constants_default.DAY:
|
|
249
|
-
case constants_default.DAY_OF_MONTH:
|
|
250
|
-
instanceFactorySet(constants_default.HOUR, 0);
|
|
251
|
-
break;
|
|
252
|
-
case constants_default.HOUR:
|
|
253
|
-
instanceFactorySet(constants_default.MIN, 1);
|
|
254
|
-
break;
|
|
255
|
-
case constants_default.MIN:
|
|
256
|
-
instanceFactorySet(constants_default.SECOND, 2);
|
|
257
|
-
break;
|
|
258
|
-
case constants_default.SECOND:
|
|
259
|
-
instanceFactorySet(constants_default.MS, 3);
|
|
260
|
-
break;
|
|
261
|
-
default: break;
|
|
262
|
-
}
|
|
263
|
-
return result;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js
|
|
268
|
-
var require_checkPrivateRedeclaration = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js": ((exports, module) => {
|
|
269
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
270
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
271
|
-
}
|
|
272
|
-
module.exports = _checkPrivateRedeclaration, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
273
|
-
}) });
|
|
274
|
-
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js
|
|
277
|
-
var require_classPrivateMethodInitSpec = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js": ((exports, module) => {
|
|
278
|
-
var checkPrivateRedeclaration = require_checkPrivateRedeclaration();
|
|
279
|
-
function _classPrivateMethodInitSpec$1(e, a) {
|
|
280
|
-
checkPrivateRedeclaration(e, a), a.add(e);
|
|
281
|
-
}
|
|
282
|
-
module.exports = _classPrivateMethodInitSpec$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
283
|
-
}) });
|
|
284
|
-
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
287
|
-
var require_typeof = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/typeof.js": ((exports, module) => {
|
|
288
|
-
function _typeof$2(o) {
|
|
289
|
-
"@babel/helpers - typeof";
|
|
290
|
-
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
291
|
-
return typeof o$1;
|
|
292
|
-
} : function(o$1) {
|
|
293
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
294
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
295
|
-
}
|
|
296
|
-
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
297
|
-
}) });
|
|
298
|
-
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
301
|
-
var require_toPrimitive = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js": ((exports, module) => {
|
|
302
|
-
var _typeof$1 = require_typeof()["default"];
|
|
303
|
-
function toPrimitive$1(t, r) {
|
|
304
|
-
if ("object" != _typeof$1(t) || !t) return t;
|
|
305
|
-
var e = t[Symbol.toPrimitive];
|
|
306
|
-
if (void 0 !== e) {
|
|
307
|
-
var i = e.call(t, r || "default");
|
|
308
|
-
if ("object" != _typeof$1(i)) return i;
|
|
309
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
310
|
-
}
|
|
311
|
-
return ("string" === r ? String : Number)(t);
|
|
312
|
-
}
|
|
313
|
-
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
314
|
-
}) });
|
|
315
|
-
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
318
|
-
var require_toPropertyKey = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js": ((exports, module) => {
|
|
319
|
-
var _typeof = require_typeof()["default"];
|
|
320
|
-
var toPrimitive = require_toPrimitive();
|
|
321
|
-
function toPropertyKey$1(t) {
|
|
322
|
-
var i = toPrimitive(t, "string");
|
|
323
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
324
|
-
}
|
|
325
|
-
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
326
|
-
}) });
|
|
327
|
-
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
330
|
-
var require_defineProperty = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js": ((exports, module) => {
|
|
331
|
-
var toPropertyKey = require_toPropertyKey();
|
|
332
|
-
function _defineProperty$1(e, r, t) {
|
|
333
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
334
|
-
value: t,
|
|
335
|
-
enumerable: !0,
|
|
336
|
-
configurable: !0,
|
|
337
|
-
writable: !0
|
|
338
|
-
}) : e[r] = t, e;
|
|
339
|
-
}
|
|
340
|
-
module.exports = _defineProperty$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
341
|
-
}) });
|
|
342
|
-
|
|
343
|
-
//#endregion
|
|
344
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js
|
|
345
|
-
var require_assertClassBrand = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js": ((exports, module) => {
|
|
346
|
-
function _assertClassBrand$1(e, t, n) {
|
|
347
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
348
|
-
throw new TypeError("Private element is not present on this object");
|
|
349
|
-
}
|
|
350
|
-
module.exports = _assertClassBrand$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
351
|
-
}) });
|
|
352
|
-
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/core/EsDay.ts
|
|
355
|
-
var import_classPrivateMethodInitSpec = /* @__PURE__ */ __toESM(require_classPrivateMethodInitSpec(), 1);
|
|
356
|
-
var import_defineProperty = /* @__PURE__ */ __toESM(require_defineProperty(), 1);
|
|
357
|
-
var import_assertClassBrand = /* @__PURE__ */ __toESM(require_assertClassBrand(), 1);
|
|
358
|
-
var _EsDay_brand = /* @__PURE__ */ new WeakSet();
|
|
359
|
-
var EsDay = class EsDay {
|
|
360
|
-
constructor(d, conf) {
|
|
361
|
-
(0, import_classPrivateMethodInitSpec.default)(this, _EsDay_brand);
|
|
362
|
-
(0, import_defineProperty.default)(this, "$d", void 0);
|
|
363
|
-
(0, import_defineProperty.default)(this, "$conf", {});
|
|
364
|
-
if (!isUndefined(conf)) this.$conf = structuredClone(conf);
|
|
365
|
-
this.$parse(d);
|
|
366
|
-
}
|
|
367
|
-
$parse(d) {
|
|
368
|
-
this.$d = (0, import_assertClassBrand.default)(_EsDay_brand, this, _parseImpl).call(this, d);
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Create a Date object from the date components (year, month, ...).
|
|
372
|
-
* The month is 1 based (1..12).
|
|
373
|
-
* Potential hook for plugins to change the details of Date creation.
|
|
374
|
-
* @param Y - year of date to create
|
|
375
|
-
* @param M - year of date to create (1..12)
|
|
376
|
-
* @param D - year of date to create
|
|
377
|
-
* @param h - year of date to create
|
|
378
|
-
* @param m - year of date to create
|
|
379
|
-
* @param s - year of date to create
|
|
380
|
-
* @param ms - year of date to create
|
|
381
|
-
* @param offsetMs - offset from utc in milliseconds
|
|
382
|
-
* @returns Date object created from input parameters
|
|
383
|
-
*/
|
|
384
|
-
dateFromDateComponents(Y, M, D, h, m, s, ms, offsetMs) {
|
|
385
|
-
const parsedYearOrDefault = Y ?? (/* @__PURE__ */ new Date()).getFullYear();
|
|
386
|
-
const parsedMonthOrDefault = M ?? (Y !== void 0 ? 1 : (/* @__PURE__ */ new Date()).getMonth() + 1);
|
|
387
|
-
const dateComponents = {
|
|
388
|
-
Y: parsedYearOrDefault,
|
|
389
|
-
M: parsedMonthOrDefault - 1,
|
|
390
|
-
D: D ?? 1,
|
|
391
|
-
h: h ?? 0,
|
|
392
|
-
m: m ?? 0,
|
|
393
|
-
s: s ?? 0,
|
|
394
|
-
ms: ms ?? 0
|
|
395
|
-
};
|
|
396
|
-
const yearWithoutCentury = Math.abs(parsedYearOrDefault) < 100;
|
|
397
|
-
let overflowed = false;
|
|
398
|
-
let result = new Date(dateComponents.Y, dateComponents.M, dateComponents.D, dateComponents.h, dateComponents.m, dateComponents.s, dateComponents.ms);
|
|
399
|
-
if (yearWithoutCentury) result.setFullYear(dateComponents.Y);
|
|
400
|
-
overflowed = M !== void 0 && M - 1 !== result.getMonth() || D !== void 0 && D !== result.getDate() || h !== void 0 && h !== result.getHours() || m !== void 0 && m !== result.getMinutes() || s !== void 0 && s !== result.getSeconds();
|
|
401
|
-
if (overflowed) result = constants_default.INVALID_DATE;
|
|
402
|
-
else if (!isUndefined(offsetMs)) {
|
|
403
|
-
const currentOffsetMin = result.getTimezoneOffset();
|
|
404
|
-
const newMs = result.getMilliseconds() - (currentOffsetMin * 6e4 + offsetMs);
|
|
405
|
-
result.setMilliseconds(newMs);
|
|
406
|
-
}
|
|
407
|
-
return result;
|
|
408
|
-
}
|
|
409
|
-
isSame(that, units = constants_default.MS) {
|
|
410
|
-
const other = esday(that);
|
|
411
|
-
return this.startOf(units) <= other && other <= this.endOf(units);
|
|
412
|
-
}
|
|
413
|
-
isAfter(that, units = constants_default.MS) {
|
|
414
|
-
return esday(that) < this.startOf(units);
|
|
415
|
-
}
|
|
416
|
-
isBefore(that, units = constants_default.MS) {
|
|
417
|
-
return this.endOf(units) < esday(that);
|
|
418
|
-
}
|
|
419
|
-
valueOf() {
|
|
420
|
-
return this.$d.getTime();
|
|
421
|
-
}
|
|
422
|
-
unix() {
|
|
423
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
424
|
-
}
|
|
425
|
-
isValid() {
|
|
426
|
-
return isValidDate(this.$d);
|
|
427
|
-
}
|
|
428
|
-
clone() {
|
|
429
|
-
const newInst = new EsDay(this.$d);
|
|
430
|
-
newInst.$conf = structuredClone(this.$conf);
|
|
431
|
-
return newInst;
|
|
432
|
-
}
|
|
433
|
-
format(formatStr) {
|
|
434
|
-
return formatImpl(this, formatStr);
|
|
435
|
-
}
|
|
436
|
-
startOf(units) {
|
|
437
|
-
return startOfImpl(this, units);
|
|
438
|
-
}
|
|
439
|
-
endOf(units) {
|
|
440
|
-
return startOfImpl(this, units, true);
|
|
441
|
-
}
|
|
442
|
-
add(value, unit) {
|
|
443
|
-
if (!isObject(value) && unit !== void 0) return addImpl(this, value, unit);
|
|
444
|
-
return this.clone();
|
|
445
|
-
}
|
|
446
|
-
subtract(value, unit) {
|
|
447
|
-
if (!isObject(value) && unit !== void 0) return this.add(-value, unit);
|
|
448
|
-
return this.clone();
|
|
449
|
-
}
|
|
450
|
-
diff(date, units, asFloat = false) {
|
|
451
|
-
return diffImpl(this, date, units, asFloat);
|
|
452
|
-
}
|
|
453
|
-
utcOffset(offset, _keepLocalTime) {
|
|
454
|
-
if (offset !== void 0) return new EsDay(constants_default.INVALID_DATE);
|
|
455
|
-
return -Math.round(this["$d"].getTimezoneOffset());
|
|
456
|
-
}
|
|
457
|
-
get(unit) {
|
|
458
|
-
const normalizedUnit = normalizeUnitWithPlurals(unit);
|
|
459
|
-
if (normalizedUnit === constants_default.QUARTER || normalizedUnit === constants_default.WEEK) return NaN;
|
|
460
|
-
return getUnitInDate(this.$d, unit);
|
|
461
|
-
}
|
|
462
|
-
set(unit, ...values) {
|
|
463
|
-
return this.clone().$set(unit, values);
|
|
464
|
-
}
|
|
465
|
-
toDate() {
|
|
466
|
-
return new Date(this.valueOf());
|
|
467
|
-
}
|
|
468
|
-
toJSON() {
|
|
469
|
-
return this.isValid() ? this.toISOString() : null;
|
|
470
|
-
}
|
|
471
|
-
toISOString() {
|
|
472
|
-
if (this.isValid()) return this.$d.toISOString();
|
|
473
|
-
return constants_default.INVALID_DATE_STRING;
|
|
474
|
-
}
|
|
475
|
-
toString() {
|
|
476
|
-
return this.$d.toUTCString();
|
|
477
|
-
}
|
|
478
|
-
$set(unit, values) {
|
|
479
|
-
if (isObject(unit)) return this.clone();
|
|
480
|
-
const normalizedUnit = normalizeUnitWithPlurals(unit);
|
|
481
|
-
if (normalizedUnit === constants_default.DAY) setUnitInDate(this.$d, constants_default.DAY_OF_MONTH, this.date() + (values[0] - this.day()));
|
|
482
|
-
else if (normalizedUnit === constants_default.MONTH) {
|
|
483
|
-
const originalDate = values.length === 1 ? this.date() : values[1];
|
|
484
|
-
setUnitInDate(this.$d, constants_default.MONTH, values);
|
|
485
|
-
if (originalDate > 0 && this.date() !== originalDate) setUnitInDate(this.$d, constants_default.DAY_OF_MONTH, 0);
|
|
486
|
-
} else if (normalizedUnit !== constants_default.QUARTER && normalizedUnit !== constants_default.WEEK) {
|
|
487
|
-
const typedUnit = normalizedUnit;
|
|
488
|
-
setUnitInDate(this.$d, typedUnit, values);
|
|
489
|
-
}
|
|
490
|
-
return this;
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
/**
|
|
494
|
-
* Convert a parsed element to a number | undefined;
|
|
495
|
-
* empty strings are treated as undefined.
|
|
496
|
-
* @param parsedElement - element to be converted
|
|
497
|
-
* @returns parsed element as number
|
|
498
|
-
*/
|
|
499
|
-
function _toNumber(parsedElement) {
|
|
500
|
-
if (parsedElement === void 0 || typeof parsedElement === "string" && parsedElement.trim().length === 0) return;
|
|
501
|
-
return Number(parsedElement);
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Convert a parsed milliseconds element to a number | undefined;
|
|
505
|
-
* for milliseconds only the 1st 3 digits are considered;
|
|
506
|
-
* empty strings are treated as '0'.
|
|
507
|
-
* @param parsedElement - element to be converted
|
|
508
|
-
* @returns parsed element as number
|
|
509
|
-
*/
|
|
510
|
-
function _toMsNumber(parsedElement) {
|
|
511
|
-
if (parsedElement === void 0) return;
|
|
512
|
-
return Number(parsedElement.toString().slice(0, 3));
|
|
513
|
-
}
|
|
514
|
-
function _parseImpl(date) {
|
|
515
|
-
if (date instanceof Date) return new Date(date);
|
|
516
|
-
if (date === null) return /* @__PURE__ */ new Date(NaN);
|
|
517
|
-
if (isUndefined(date)) return /* @__PURE__ */ new Date();
|
|
518
|
-
if (isEmptyObject(date)) return /* @__PURE__ */ new Date();
|
|
519
|
-
if (Array.isArray(date)) return parseArrayToDate.call(this, date);
|
|
520
|
-
if (typeof date === "string" && !/Z$/i.test(date)) {
|
|
521
|
-
const d = date.match(constants_default.REGEX_PARSE_DEFAULT);
|
|
522
|
-
if (d) {
|
|
523
|
-
const Y = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[1]);
|
|
524
|
-
const M = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[2]);
|
|
525
|
-
const D = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[3]);
|
|
526
|
-
const h = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[4]);
|
|
527
|
-
const m = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[5]);
|
|
528
|
-
const s = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[6]);
|
|
529
|
-
const ms = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toMsNumber).call(this, d[7]);
|
|
530
|
-
return this.dateFromDateComponents(Y, M, D, h, m, s, ms);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
return new Date(date);
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Getter / Setter for date components:
|
|
537
|
-
* esday().year(...args)
|
|
538
|
-
* esday().month(...args)
|
|
539
|
-
* esday().date(...args)
|
|
540
|
-
* esday().day(...args)
|
|
541
|
-
* esday().hour(...args)
|
|
542
|
-
* esday().minute(...args)
|
|
543
|
-
* esday().second(...args)
|
|
544
|
-
* esday().millisecond(...args)
|
|
545
|
-
*/
|
|
546
|
-
for (const key of prettyUnitsDate) EsDay.prototype[key] = function(...args) {
|
|
547
|
-
if (args?.length) return this.set(key, ...args);
|
|
548
|
-
return this.get(key);
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region src/core/factory.ts
|
|
553
|
-
const esday = (d, ...others) => {
|
|
554
|
-
if (d instanceof EsDay) return d.clone();
|
|
555
|
-
const conf = {};
|
|
556
|
-
others.forEach((o, i) => {
|
|
557
|
-
if (isArray(o)) conf[`args_${i + 1}`] = o;
|
|
558
|
-
else if (isObject(o)) Object.assign(conf, o);
|
|
559
|
-
else conf[`args_${i + 1}`] = o;
|
|
560
|
-
});
|
|
561
|
-
return new EsDay(d, conf);
|
|
562
|
-
};
|
|
563
|
-
esday.addFormatTokenDefinitions = addFormatTokenDefinitions;
|
|
564
|
-
esday.extend = (plugin, option) => {
|
|
565
|
-
if (!plugin.$i) {
|
|
566
|
-
plugin(option || {}, EsDay, esday);
|
|
567
|
-
plugin.$i = true;
|
|
568
|
-
}
|
|
569
|
-
return esday;
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
//#endregion
|
|
573
3
|
export { EsDay, esday };
|
package/locales/af.d.ts
CHANGED
package/locales/af.js
CHANGED
|
@@ -56,6 +56,7 @@ const localeAf = {
|
|
|
56
56
|
"Nov",
|
|
57
57
|
"Des"
|
|
58
58
|
],
|
|
59
|
+
dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
|
|
59
60
|
ordinal: (n) => `${n}`,
|
|
60
61
|
weekStart: 1,
|
|
61
62
|
yearStart: 4,
|
|
@@ -90,6 +91,8 @@ const localeAf = {
|
|
|
90
91
|
hh: "%d ure",
|
|
91
92
|
d: "n dag",
|
|
92
93
|
dd: "%d dae",
|
|
94
|
+
w: "n week",
|
|
95
|
+
ww: "%d weke",
|
|
93
96
|
M: "n maand",
|
|
94
97
|
MM: "%d maande",
|
|
95
98
|
y: "n jaar",
|
|
@@ -100,7 +103,6 @@ const localeAf = {
|
|
|
100
103
|
return isLowercase ? m.toLowerCase() : m;
|
|
101
104
|
}
|
|
102
105
|
};
|
|
103
|
-
var af_default = localeAf;
|
|
104
106
|
|
|
105
107
|
//#endregion
|
|
106
|
-
export {
|
|
108
|
+
export { localeAf as default };
|
package/locales/am.d.ts
CHANGED
package/locales/am.js
CHANGED
|
@@ -56,6 +56,7 @@ const localeAm = {
|
|
|
56
56
|
"ኖቬም",
|
|
57
57
|
"ዲሴም"
|
|
58
58
|
],
|
|
59
|
+
dayOfMonthOrdinalParse: /\d{1,2}/,
|
|
59
60
|
ordinal: (n) => `${n}ኛ`,
|
|
60
61
|
weekStart: 1,
|
|
61
62
|
yearStart: 4,
|
|
@@ -90,6 +91,8 @@ const localeAm = {
|
|
|
90
91
|
hh: "%d ሰዓታት",
|
|
91
92
|
d: "አንድ ቀን",
|
|
92
93
|
dd: "%d ቀናት",
|
|
94
|
+
w: "አንድ ሳምንት",
|
|
95
|
+
ww: "%d ሳምንታት",
|
|
93
96
|
M: "አንድ ወር",
|
|
94
97
|
MM: "%d ወራት",
|
|
95
98
|
y: "አንድ ዓመት",
|
|
@@ -100,7 +103,6 @@ const localeAm = {
|
|
|
100
103
|
return isLowercase ? m.toLowerCase() : m;
|
|
101
104
|
}
|
|
102
105
|
};
|
|
103
|
-
var am_default = localeAm;
|
|
104
106
|
|
|
105
107
|
//#endregion
|
|
106
|
-
export {
|
|
108
|
+
export { localeAm as default };
|
package/locales/ar-dz.d.ts
CHANGED
package/locales/ar-dz.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "../
|
|
3
|
-
import "../chunks/DjY7KvwG.js";
|
|
4
|
-
import { ar_default } from "../chunks/BeVgU2nj.js";
|
|
5
|
-
import "../chunks/tfkJ5D3p.js";
|
|
6
|
-
import { cloneLocale, setLocaleProperty } from "../chunks/CoBtJ4c1.js";
|
|
1
|
+
import locale from "./ar.js";
|
|
2
|
+
import { cloneLocale, setLocaleProperty } from "../plugins/locale/index.js";
|
|
7
3
|
|
|
8
4
|
//#region src/locales/ar-dz.ts
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Arabic (Algeria) [ar-DZ]
|
|
7
|
+
*/
|
|
8
|
+
const localeArDz = cloneLocale(locale);
|
|
10
9
|
const months = [
|
|
11
10
|
"جانفي",
|
|
12
11
|
"فيفري",
|
|
@@ -26,7 +25,6 @@ setLocaleProperty(localeArDz, "months", months);
|
|
|
26
25
|
setLocaleProperty(localeArDz, "monthsShort", months);
|
|
27
26
|
setLocaleProperty(localeArDz, "weekStart", 0);
|
|
28
27
|
setLocaleProperty(localeArDz, "yearStart", 4);
|
|
29
|
-
var ar_dz_default = localeArDz;
|
|
30
28
|
|
|
31
29
|
//#endregion
|
|
32
|
-
export {
|
|
30
|
+
export { localeArDz as default };
|