esday 0.4.1 → 0.5.0
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 +8 -0
- package/LICENSE +21 -0
- package/README.md +20 -2
- package/chunks/B5f9poqo.js +120 -0
- package/chunks/BDssPbM_.js +106 -0
- package/chunks/BRRrAbUl.js +56 -0
- package/chunks/BXRGSAJG.js +128 -0
- package/chunks/BeVgU2nj.js +188 -0
- package/chunks/BtmEtAW3.js +43 -0
- package/chunks/CQ57zhVp.js +106 -0
- package/chunks/CQJ0-ZuR.js +106 -0
- package/chunks/CWqzr5E5.js +108 -0
- package/chunks/Cb5SvF6r.js +25 -0
- package/chunks/Cg4ZI9v8.js +180 -0
- package/chunks/CoBtJ4c1.js +144 -0
- package/chunks/D009Z-ld.js +109 -0
- package/chunks/DMtTiWuY.js +127 -0
- package/chunks/DXHbH1CI.js +9 -0
- package/chunks/Dixb5KKs.js +116 -0
- package/chunks/DjY7KvwG.js +28 -0
- package/chunks/DqhiVwLi.d.ts +203 -0
- package/chunks/GjKpN6U-.js +135 -0
- package/chunks/MtjcOKi-.d.ts +6 -0
- package/chunks/St35qgL0.d.ts +103 -0
- package/chunks/Y32qdU_5.js +62 -0
- package/chunks/br7kModF.js +110 -0
- package/chunks/l2Rxo2H0.js +106 -0
- package/chunks/tfkJ5D3p.js +115 -0
- package/index.d.ts +3 -6
- package/index.js +556 -293
- package/locales/af.d.ts +8 -0
- package/locales/af.js +106 -0
- package/locales/am.d.ts +8 -0
- package/locales/am.js +106 -0
- package/locales/ar-dz.d.ts +11 -0
- package/locales/ar-dz.js +32 -0
- package/locales/ar-iq.d.ts +11 -0
- package/locales/ar-iq.js +14 -0
- package/locales/ar-kw.d.ts +11 -0
- package/locales/ar-kw.js +28 -0
- package/locales/ar-ly.d.ts +11 -0
- package/locales/ar-ly.js +14 -0
- package/locales/ar-ma.d.ts +11 -0
- package/locales/ar-ma.js +29 -0
- package/locales/ar-sa.d.ts +11 -0
- package/locales/ar-sa.js +29 -0
- package/locales/ar-tn.d.ts +11 -0
- package/locales/ar-tn.js +29 -0
- package/locales/ar.d.ts +8 -0
- package/locales/ar.js +3 -0
- package/locales/az.d.ts +8 -0
- package/locales/az.js +106 -0
- package/locales/be.d.ts +8 -0
- package/locales/be.js +140 -0
- package/locales/bg.d.ts +8 -0
- package/locales/bg.js +125 -0
- package/locales/bi.d.ts +8 -0
- package/locales/bi.js +106 -0
- package/locales/bm.d.ts +8 -0
- package/locales/bm.js +106 -0
- package/locales/bn-bd.d.ts +11 -0
- package/locales/bn-bd.js +24 -0
- package/locales/bn.d.ts +8 -0
- package/locales/bn.js +3 -0
- package/locales/bo.d.ts +8 -0
- package/locales/bo.js +106 -0
- package/locales/br.d.ts +8 -0
- package/locales/br.js +179 -0
- package/locales/bs.d.ts +8 -0
- package/locales/bs.js +128 -0
- package/locales/ca.d.ts +8 -0
- package/locales/ca.js +143 -0
- package/locales/cs.d.ts +8 -0
- package/locales/cs.js +182 -0
- package/locales/cv.d.ts +8 -0
- package/locales/cv.js +106 -0
- package/locales/cy.d.ts +8 -0
- package/locales/cy.js +106 -0
- package/locales/da.d.ts +8 -0
- package/locales/da.js +106 -0
- package/locales/de-at.d.ts +11 -0
- package/locales/de-at.js +44 -0
- package/locales/de-ch.d.ts +11 -0
- package/locales/de-ch.js +14 -0
- package/locales/de.d.ts +8 -0
- package/locales/de.js +3 -0
- package/locales/dv.d.ts +8 -0
- package/locales/dv.js +106 -0
- package/locales/el.d.ts +8 -0
- package/locales/el.js +115 -0
- package/locales/en-au.d.ts +11 -0
- package/locales/en-au.js +27 -0
- package/locales/en-ca.d.ts +11 -0
- package/locales/en-ca.js +27 -0
- package/locales/en-gb.d.ts +13 -0
- package/locales/en-gb.js +28 -0
- package/locales/en-ie.d.ts +11 -0
- package/locales/en-ie.js +26 -0
- package/locales/en-il.d.ts +11 -0
- package/locales/en-il.js +28 -0
- package/locales/en-in.d.ts +11 -0
- package/locales/en-in.js +26 -0
- package/locales/en-nz.d.ts +11 -0
- package/locales/en-nz.js +28 -0
- package/locales/en-sg.d.ts +11 -0
- package/locales/en-sg.js +28 -0
- package/locales/en-tt.d.ts +11 -0
- package/locales/en-tt.js +28 -0
- package/locales/en-us.d.ts +11 -0
- package/locales/en-us.js +13 -0
- package/locales/en.d.ts +7 -5
- package/locales/en.js +3 -1
- package/locales/eo.d.ts +8 -0
- package/locales/eo.js +106 -0
- package/locales/es-do.d.ts +11 -0
- package/locales/es-do.js +27 -0
- package/locales/es-mx.d.ts +11 -0
- package/locales/es-mx.js +15 -0
- package/locales/es-pr.d.ts +11 -0
- package/locales/es-pr.js +18 -0
- package/locales/es-us.d.ts +11 -0
- package/locales/es-us.js +14 -0
- package/locales/es.d.ts +8 -0
- package/locales/es.js +3 -0
- package/locales/et.d.ts +8 -0
- package/locales/et.js +142 -0
- package/locales/eu.d.ts +8 -0
- package/locales/eu.js +106 -0
- package/locales/fa.d.ts +8 -0
- package/locales/fa.js +106 -0
- package/locales/fi.d.ts +8 -0
- package/locales/fi.js +165 -0
- package/locales/fil.d.ts +8 -0
- package/locales/fil.js +106 -0
- package/locales/fo.d.ts +8 -0
- package/locales/fo.js +106 -0
- package/locales/fr-ca.d.ts +11 -0
- package/locales/fr-ca.js +18 -0
- package/locales/fr-ch.d.ts +11 -0
- package/locales/fr-ch.js +18 -0
- package/locales/fr.d.ts +8 -0
- package/locales/fr.js +3 -0
- package/locales/fy.d.ts +8 -0
- package/locales/fy.js +106 -0
- package/locales/ga.d.ts +8 -0
- package/locales/ga.js +106 -0
- package/locales/gd.d.ts +8 -0
- package/locales/gd.js +106 -0
- package/locales/gl.d.ts +8 -0
- package/locales/gl.js +116 -0
- package/locales/gom-deva.d.ts +8 -0
- package/locales/gom-deva.js +146 -0
- package/locales/gom-latn.d.ts +8 -0
- package/locales/gom-latn.js +146 -0
- package/locales/gu.d.ts +8 -0
- package/locales/gu.js +106 -0
- package/locales/he.d.ts +8 -0
- package/locales/he.js +129 -0
- package/locales/hi.d.ts +8 -0
- package/locales/hi.js +125 -0
- package/locales/hr.d.ts +8 -0
- package/locales/hr.js +189 -0
- package/locales/ht.d.ts +8 -0
- package/locales/ht.js +106 -0
- package/locales/hu.d.ts +8 -0
- package/locales/hu.js +140 -0
- package/locales/hy-am.d.ts +8 -0
- package/locales/hy-am.js +127 -0
- package/locales/id.d.ts +8 -0
- package/locales/id.js +106 -0
- package/locales/is.d.ts +8 -0
- package/locales/is.js +155 -0
- package/locales/it-ch.d.ts +11 -0
- package/locales/it-ch.js +32 -0
- package/locales/it.d.ts +8 -0
- package/locales/it.js +3 -0
- package/locales/ja.d.ts +15 -0
- package/locales/ja.js +109 -0
- package/locales/jv.d.ts +8 -0
- package/locales/jv.js +106 -0
- package/locales/ka.d.ts +8 -0
- package/locales/ka.js +126 -0
- package/locales/kk.d.ts +8 -0
- package/locales/kk.js +106 -0
- package/locales/km.d.ts +8 -0
- package/locales/km.js +106 -0
- package/locales/kn.d.ts +8 -0
- package/locales/kn.js +106 -0
- package/locales/ko.d.ts +8 -0
- package/locales/ko.js +105 -0
- package/locales/ku.d.ts +8 -0
- package/locales/ku.js +119 -0
- package/locales/ky.d.ts +8 -0
- package/locales/ky.js +106 -0
- package/locales/lb.d.ts +8 -0
- package/locales/lb.js +166 -0
- package/locales/lo.d.ts +8 -0
- package/locales/lo.js +105 -0
- package/locales/lt.d.ts +8 -0
- package/locales/lt.js +106 -0
- package/locales/lv.d.ts +8 -0
- package/locales/lv.js +106 -0
- package/locales/me.d.ts +8 -0
- package/locales/me.js +129 -0
- package/locales/mi.d.ts +8 -0
- package/locales/mi.js +106 -0
- package/locales/mk.d.ts +8 -0
- package/locales/mk.js +117 -0
- package/locales/ml.d.ts +8 -0
- package/locales/ml.js +109 -0
- package/locales/mn.d.ts +8 -0
- package/locales/mn.js +106 -0
- package/locales/mr.d.ts +8 -0
- package/locales/mr.js +215 -0
- package/locales/ms-my.d.ts +11 -0
- package/locales/ms-my.js +14 -0
- package/locales/ms.d.ts +8 -0
- package/locales/ms.js +3 -0
- package/locales/mt.d.ts +8 -0
- package/locales/mt.js +106 -0
- package/locales/my.d.ts +8 -0
- package/locales/my.js +132 -0
- package/locales/nb.d.ts +8 -0
- package/locales/nb.js +106 -0
- package/locales/ne.d.ts +8 -0
- package/locales/ne.js +106 -0
- package/locales/nl-be.d.ts +11 -0
- package/locales/nl-be.js +18 -0
- package/locales/nl.d.ts +8 -0
- package/locales/nl.js +3 -0
- package/locales/nn.d.ts +8 -0
- package/locales/nn.js +106 -0
- package/locales/oc-lnc.d.ts +8 -0
- package/locales/oc-lnc.js +126 -0
- package/locales/pa-in.d.ts +8 -0
- package/locales/pa-in.js +123 -0
- package/locales/pl.d.ts +8 -0
- package/locales/pl.js +159 -0
- package/locales/pt-br.d.ts +11 -0
- package/locales/pt-br.js +53 -0
- package/locales/pt.d.ts +8 -0
- package/locales/pt.js +3 -0
- package/locales/rn.d.ts +8 -0
- package/locales/rn.js +106 -0
- package/locales/ro.d.ts +8 -0
- package/locales/ro.js +106 -0
- package/locales/ru.d.ts +15 -0
- package/locales/ru.js +236 -0
- package/locales/rw.d.ts +8 -0
- package/locales/rw.js +106 -0
- package/locales/sd.d.ts +8 -0
- package/locales/sd.js +106 -0
- package/locales/se.d.ts +8 -0
- package/locales/se.js +106 -0
- package/locales/si.d.ts +8 -0
- package/locales/si.js +106 -0
- package/locales/sk.d.ts +8 -0
- package/locales/sk.js +162 -0
- package/locales/sl.d.ts +8 -0
- package/locales/sl.js +171 -0
- package/locales/sq.d.ts +8 -0
- package/locales/sq.js +106 -0
- package/locales/sr-cyrl.d.ts +11 -0
- package/locales/sr-cyrl.js +173 -0
- package/locales/sr.d.ts +8 -0
- package/locales/sr.js +3 -0
- package/locales/ss.d.ts +8 -0
- package/locales/ss.js +108 -0
- package/locales/sv-fi.d.ts +11 -0
- package/locales/sv-fi.js +27 -0
- package/locales/sv.d.ts +8 -0
- package/locales/sv.js +3 -0
- package/locales/sw.d.ts +8 -0
- package/locales/sw.js +106 -0
- package/locales/ta.d.ts +8 -0
- package/locales/ta.js +137 -0
- package/locales/te.d.ts +8 -0
- package/locales/te.js +109 -0
- package/locales/tet.d.ts +8 -0
- package/locales/tet.js +110 -0
- package/locales/tg.d.ts +8 -0
- package/locales/tg.js +128 -0
- package/locales/th.d.ts +8 -0
- package/locales/th.js +106 -0
- package/locales/tk.d.ts +8 -0
- package/locales/tk.js +134 -0
- package/locales/tl-ph.d.ts +8 -0
- package/locales/tl-ph.js +106 -0
- package/locales/tlh.d.ts +8 -0
- package/locales/tlh.js +152 -0
- package/locales/tr.d.ts +8 -0
- package/locales/tr.js +134 -0
- package/locales/tzl.d.ts +8 -0
- package/locales/tzl.js +123 -0
- package/locales/tzm-latn.d.ts +11 -0
- package/locales/tzm-latn.js +68 -0
- package/locales/tzm.d.ts +8 -0
- package/locales/tzm.js +3 -0
- package/locales/ug-cn.d.ts +8 -0
- package/locales/ug-cn.js +111 -0
- package/locales/uk.d.ts +8 -0
- package/locales/uk.js +194 -0
- package/locales/ur.d.ts +8 -0
- package/locales/ur.js +108 -0
- package/locales/uz-latn.d.ts +11 -0
- package/locales/uz-latn.js +68 -0
- package/locales/uz.d.ts +8 -0
- package/locales/uz.js +3 -0
- package/locales/vi.d.ts +8 -0
- package/locales/vi.js +106 -0
- package/locales/x-pseudo.d.ts +8 -0
- package/locales/x-pseudo.js +110 -0
- package/locales/yo.d.ts +8 -0
- package/locales/yo.js +106 -0
- package/locales/zh-cn.d.ts +11 -0
- package/locales/zh-cn.js +14 -0
- package/locales/zh-hk.d.ts +11 -0
- package/locales/zh-hk.js +23 -0
- package/locales/zh-mo.d.ts +11 -0
- package/locales/zh-mo.js +23 -0
- package/locales/zh-tw.d.ts +11 -0
- package/locales/zh-tw.js +23 -0
- package/locales/zh.d.ts +13 -4
- package/locales/zh.js +2 -63
- package/package.json +51 -25
- package/plugins/advancedFormat/index.d.ts +8 -0
- package/plugins/advancedFormat/index.js +20 -0
- package/plugins/advancedParse/index.d.ts +8 -0
- package/plugins/advancedParse/index.js +406 -0
- package/plugins/calendar/index.d.ts +14 -0
- package/plugins/calendar/index.js +33 -0
- package/plugins/dayOfYear/index.d.ts +13 -0
- package/plugins/dayOfYear/index.js +12 -0
- package/plugins/isBetween/index.d.ts +23 -0
- package/plugins/isBetween/index.js +16 -0
- package/plugins/isLeapYear/index.d.ts +12 -0
- package/plugins/isLeapYear/index.js +11 -0
- package/plugins/isSameOrAfter/index.d.ts +12 -0
- package/plugins/isSameOrAfter/index.js +10 -0
- package/plugins/isSameOrBefore/index.d.ts +12 -0
- package/plugins/isSameOrBefore/index.js +10 -0
- package/plugins/isToday/index.d.ts +8 -6
- package/plugins/isToday/index.js +10 -6
- package/plugins/isTomorrow/index.d.ts +12 -0
- package/plugins/isTomorrow/index.js +14 -0
- package/plugins/isYesterday/index.d.ts +12 -0
- package/plugins/isYesterday/index.js +14 -0
- package/plugins/isoWeek/index.d.ts +21 -0
- package/plugins/isoWeek/index.js +240 -0
- package/plugins/locale/index.d.ts +4 -75
- package/plugins/locale/index.js +6 -69
- package/plugins/localeData/index.d.ts +8 -0
- package/plugins/localeData/index.js +148 -0
- package/plugins/localizedFormat/index.d.ts +8 -0
- package/plugins/localizedFormat/index.js +88 -0
- package/plugins/localizedParse/index.d.ts +8 -0
- package/plugins/localizedParse/index.js +199 -0
- package/plugins/minMax/index.d.ts +13 -0
- package/plugins/minMax/index.js +22 -0
- package/plugins/objectSupport/index.d.ts +8 -0
- package/plugins/objectSupport/index.js +104 -0
- package/plugins/pluralGetSet/index.d.ts +20 -0
- package/plugins/pluralGetSet/index.js +16 -0
- package/plugins/quarterOfYear/index.d.ts +16 -0
- package/plugins/quarterOfYear/index.js +58 -0
- package/plugins/relativeTime/index.d.ts +59 -0
- package/plugins/relativeTime/index.js +154 -0
- package/plugins/toArray/index.d.ts +12 -0
- package/plugins/toArray/index.js +18 -0
- package/plugins/toObject/index.d.ts +20 -0
- package/plugins/toObject/index.js +18 -0
- package/plugins/utc/index.d.ts +14 -17
- package/plugins/utc/index.js +191 -37
- package/plugins/week/index.d.ts +21 -0
- package/plugins/week/index.js +360 -0
- package/EsDay-KXQgnL1r.d.ts +0 -89
- package/chunk-MLKGABMK.js +0 -7
- package/chunk-NUV73YDM.js +0 -60
- package/chunk-SQBPUYUY.js +0 -140
- package/plugins/customParseFormat/index.d.ts +0 -5
- package/plugins/customParseFormat/index.js +0 -159
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { constants_default } from "../../chunks/Y32qdU_5.js";
|
|
2
|
+
import { isArray, isString, isUndefined, isValidDate } from "../../chunks/Cb5SvF6r.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/advancedParse/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Function to create a Date object from its date components
|
|
7
|
+
* is set to the corresponding function in the core module and
|
|
8
|
+
* requires the correct this context (e.g. for the utc plugin)!
|
|
9
|
+
*/
|
|
10
|
+
let dateFromDateComponents;
|
|
11
|
+
const invalidDate = /* @__PURE__ */ new Date("");
|
|
12
|
+
const formattingSeparatorsRegex = "(\\[[^[]*\\])|([-_:/.,()\\s]+)";
|
|
13
|
+
let formattingTokensRegex;
|
|
14
|
+
const match1 = /\d/;
|
|
15
|
+
const match2 = /\d{2}/;
|
|
16
|
+
const match3 = /\d{3}/;
|
|
17
|
+
const match4 = /\d{4}/;
|
|
18
|
+
const match1to2 = /\d\d?/;
|
|
19
|
+
const match1to4 = /\d{1,4}/;
|
|
20
|
+
const matchSigned = /[+-]?\d+/;
|
|
21
|
+
const matchUnsigned = /\d+/;
|
|
22
|
+
const matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
|
23
|
+
const matchOffset = /[+-]\d\d:?(\d\d)?|Z/;
|
|
24
|
+
const parseTokensDefinitions = {};
|
|
25
|
+
/**
|
|
26
|
+
* Convert 2-digit year to 4-digit year.
|
|
27
|
+
* Years > 68 are converted to 19xx;
|
|
28
|
+
* else they are converted to 20xx.
|
|
29
|
+
* @param input value to convert to a year
|
|
30
|
+
* @returns converted 4-digit year
|
|
31
|
+
*/
|
|
32
|
+
function parseTwoDigitYear(input) {
|
|
33
|
+
const inputLimited = input.slice(0, 2);
|
|
34
|
+
const year = +inputLimited;
|
|
35
|
+
return year + (year > 68 ? 1900 : 2e3);
|
|
36
|
+
}
|
|
37
|
+
function parseFourDigitYear(input) {
|
|
38
|
+
if (input.length === 2) return parseTwoDigitYear(input);
|
|
39
|
+
return +input;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Convert 2-digit offset as string to offset as minutes (number)
|
|
43
|
+
* @param offset - parsed string representing the offset (e.g. '+10:00)
|
|
44
|
+
* @returns offset in minutes
|
|
45
|
+
*/
|
|
46
|
+
function offsetFromString(offset) {
|
|
47
|
+
if (offset === "Z") return 0;
|
|
48
|
+
const parts = offset.match(/([+-]|\d\d)/g);
|
|
49
|
+
const minutes = +parts[1] * 60 + (+parts[2] || 0);
|
|
50
|
+
return parts[0] === "+" ? minutes : -minutes;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a function that will add a value from the input string
|
|
54
|
+
* to parsedElements, containing the date&time components.
|
|
55
|
+
* @param property - name of the date&time component to add
|
|
56
|
+
* @returns function that will add the given value to date&time component
|
|
57
|
+
*/
|
|
58
|
+
function addInput(property) {
|
|
59
|
+
return (parsedElements, input) => {
|
|
60
|
+
if (property !== "afternoon") parsedElements[property] = +input;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a function that will add a milliseconds value from the input
|
|
65
|
+
* string to parsedElements, containing the date&time components.
|
|
66
|
+
* If the input string has more than 3 characters, only the first 3 characters
|
|
67
|
+
* get evaluated.
|
|
68
|
+
* @returns function that will add the given value to the milliseconds property of date&time component
|
|
69
|
+
*/
|
|
70
|
+
function addMillisecondsToInput() {
|
|
71
|
+
return (parsedElements, input) => {
|
|
72
|
+
const inputLimited = input.slice(0, 3);
|
|
73
|
+
let value = +inputLimited;
|
|
74
|
+
switch (inputLimited.length) {
|
|
75
|
+
case 1:
|
|
76
|
+
value *= 100;
|
|
77
|
+
break;
|
|
78
|
+
case 2:
|
|
79
|
+
value *= 10;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
parsedElements.milliseconds = value;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compare 2 tokens for sorting.
|
|
87
|
+
* Longer token and upper case token are sorted to the top.
|
|
88
|
+
* As we sort here object keys, a and b can never be equal.
|
|
89
|
+
* @param a - token 1
|
|
90
|
+
* @param b - token 2
|
|
91
|
+
* @returns -1 (a<b), 0 (a==b), 1 (a>b)
|
|
92
|
+
*/
|
|
93
|
+
function compareTokens(a, b) {
|
|
94
|
+
if (a.length < b.length) return 1;
|
|
95
|
+
if (a.length > b.length) return -1;
|
|
96
|
+
if (a < b) return 1;
|
|
97
|
+
return -1;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get regex from list of supported tokens.
|
|
101
|
+
*/
|
|
102
|
+
function formattingTokensRegexFromDefinitions() {
|
|
103
|
+
const tokenKeys = Object.keys(parseTokensDefinitions).sort(compareTokens);
|
|
104
|
+
formattingTokensRegex = new RegExp(`${formattingSeparatorsRegex}|(${tokenKeys.join("|")})`, "g");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build a parser that will parse an input string an return an
|
|
108
|
+
* object with the components of a date&time, the number of characters in input
|
|
109
|
+
* not parsed and the number of unused token (i.e. not enough characters in input).
|
|
110
|
+
* @param format - format to parse
|
|
111
|
+
* @param isStrict - must input match format exactly?
|
|
112
|
+
* @returns function that will parse an input string to a 'parsedResultRaw' object
|
|
113
|
+
*/
|
|
114
|
+
function makeParser(format, isStrict) {
|
|
115
|
+
const splittedFormat = format.match(formattingTokensRegex) ?? [];
|
|
116
|
+
const length = splittedFormat.length;
|
|
117
|
+
const parsingDefinitions = Array(length);
|
|
118
|
+
const postParseHandlers = [];
|
|
119
|
+
for (let i = 0; i < length; i += 1) {
|
|
120
|
+
const token = splittedFormat[i];
|
|
121
|
+
const parseTo = parseTokensDefinitions[token];
|
|
122
|
+
const regex = isStrict ? parseTo?.[1] : parseTo?.[0];
|
|
123
|
+
const updater = parseTo?.[2];
|
|
124
|
+
if (isUndefined(updater)) parsingDefinitions[i] = token.replace(/^\[|\]$/g, "");
|
|
125
|
+
else parsingDefinitions[i] = {
|
|
126
|
+
regex,
|
|
127
|
+
updater
|
|
128
|
+
};
|
|
129
|
+
const postParseHandler = parseTo?.[3];
|
|
130
|
+
if (postParseHandler !== void 0 && !postParseHandlers.includes(postParseHandler)) postParseHandlers.push(postParseHandler);
|
|
131
|
+
}
|
|
132
|
+
const parser = (input, isStrict$1, parseOptions) => {
|
|
133
|
+
let unusedTokens = 0;
|
|
134
|
+
let separatorsMatch = true;
|
|
135
|
+
const parsedDateElements = {};
|
|
136
|
+
for (let i = 0, start = 0; i < length; i += 1) {
|
|
137
|
+
if (input.length === 0) {
|
|
138
|
+
unusedTokens = parsingDefinitions.slice(i).reduce((accumulator, currentValue) => accumulator + (isString(currentValue) ? 0 : 1), 0);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
const token = parsingDefinitions[i];
|
|
142
|
+
if (isString(token)) {
|
|
143
|
+
const separatorLength = token.length;
|
|
144
|
+
if (isStrict$1 && separatorsMatch) separatorsMatch && (separatorsMatch = input.substring(0, separatorLength) === token);
|
|
145
|
+
input = input.slice(separatorLength);
|
|
146
|
+
} else {
|
|
147
|
+
const { regex, updater } = token;
|
|
148
|
+
const part = input.slice(start);
|
|
149
|
+
const match = regex.exec(part);
|
|
150
|
+
if (match !== null) {
|
|
151
|
+
const value = match[0];
|
|
152
|
+
input = input.replace(value, "");
|
|
153
|
+
updater(parsedDateElements, value, parseOptions);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const result = {
|
|
158
|
+
dateElements: parsedDateElements,
|
|
159
|
+
charsLeftOver: input.length,
|
|
160
|
+
unusedTokens,
|
|
161
|
+
separatorsMatch
|
|
162
|
+
};
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
function postParser(parsedDate, parsedElements, parseOptions) {
|
|
166
|
+
let modifiedParsedDate = parsedDate;
|
|
167
|
+
for (let i = 0; i < postParseHandlers.length; i++) modifiedParsedDate = postParseHandlers[i].call(this, modifiedParsedDate, parsedElements, parseOptions);
|
|
168
|
+
return modifiedParsedDate;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
parser,
|
|
172
|
+
postParser
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Create a Date from the tags generated by parsing the input string.
|
|
177
|
+
* Must be called in the context of an EsDay instance.
|
|
178
|
+
* @param this - context for this function (required by dateFromDateComponents)
|
|
179
|
+
* @param elements - object containing the tags generated by parsing the input string
|
|
180
|
+
* @returns Date object created from the parsed data
|
|
181
|
+
*/
|
|
182
|
+
function parsedElementsToDate(elements) {
|
|
183
|
+
const { year, month, date, hours, minutes, seconds, milliseconds, zoneOffset, unix } = elements;
|
|
184
|
+
if (Object.keys(elements).length === 0) return constants_default.INVALID_DATE;
|
|
185
|
+
if (!isUndefined(unix)) return new Date(unix);
|
|
186
|
+
let offsetMs;
|
|
187
|
+
if (zoneOffset !== void 0) offsetMs = zoneOffset * 6e4;
|
|
188
|
+
return dateFromDateComponents.call(this, year, month, date, hours, minutes, seconds, milliseconds, offsetMs);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Parse the given input using the given format and create a Date
|
|
192
|
+
* object from the parsed elements.
|
|
193
|
+
* Must be called in the context of an EsDay instance (required by parsedElementsToDate and postParser).
|
|
194
|
+
* @param this - context for this function
|
|
195
|
+
* @param input - string to be parsed
|
|
196
|
+
* @param format - format to use
|
|
197
|
+
* @param isStrict - must input match format exactly?
|
|
198
|
+
* @param parseOptions - options for parser and postParser
|
|
199
|
+
* @returns Date object generated from the given data
|
|
200
|
+
*/
|
|
201
|
+
function parseFormattedInput(input, format, isStrict, parseOptions) {
|
|
202
|
+
const { parser, postParser } = makeParser(format, isStrict);
|
|
203
|
+
const parsedElements = parser(input, isStrict, parseOptions);
|
|
204
|
+
let parsedDate = parsedElementsToDate.call(this, parsedElements.dateElements);
|
|
205
|
+
parsedDate = postParser.call(this, parsedDate, parsedElements.dateElements, parseOptions);
|
|
206
|
+
return {
|
|
207
|
+
date: parsedDate,
|
|
208
|
+
charsLeftOver: parsedElements.charsLeftOver,
|
|
209
|
+
unusedTokens: parsedElements.unusedTokens,
|
|
210
|
+
separatorsMatch: parsedElements.separatorsMatch
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Add parsing tokens to list of global parsing tokens.
|
|
215
|
+
* @param newTokens - list of new parsing token definitions
|
|
216
|
+
*/
|
|
217
|
+
function addParseTokenDefinitions(newTokens) {
|
|
218
|
+
for (const key in newTokens) if (!Object.prototype.hasOwnProperty.call(parseTokensDefinitions, key)) parseTokensDefinitions[key] = newTokens[key];
|
|
219
|
+
formattingTokensRegexFromDefinitions();
|
|
220
|
+
}
|
|
221
|
+
const advancedParsePlugin = (_, dayClass, dayFactory) => {
|
|
222
|
+
dayFactory.addParseTokenDefinitions = addParseTokenDefinitions;
|
|
223
|
+
const proto = dayClass.prototype;
|
|
224
|
+
/**
|
|
225
|
+
* List of parsing tokens; the key of an entry in this list is
|
|
226
|
+
* the token to be parsed and the value is a 3-entries-array with
|
|
227
|
+
* the 1st entry being the regex for parsing in 'standard' mode,
|
|
228
|
+
* the 2nd entry being the regex for parsing in 'strict' mode and
|
|
229
|
+
* the 3rd entry being a function that will add the corresponding
|
|
230
|
+
* value to an object containing all the date&time elements (year,
|
|
231
|
+
* month, day, ...).
|
|
232
|
+
*/
|
|
233
|
+
const parseTokensDefinitions$1 = {
|
|
234
|
+
Q: [
|
|
235
|
+
match1,
|
|
236
|
+
match1,
|
|
237
|
+
(parsedElements, input) => {
|
|
238
|
+
parsedElements.month = (Number.parseInt(input, 10) - 1) * 3 + 1;
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
S: [
|
|
242
|
+
matchUnsigned,
|
|
243
|
+
match1,
|
|
244
|
+
addMillisecondsToInput()
|
|
245
|
+
],
|
|
246
|
+
SS: [
|
|
247
|
+
matchUnsigned,
|
|
248
|
+
match2,
|
|
249
|
+
addMillisecondsToInput()
|
|
250
|
+
],
|
|
251
|
+
SSS: [
|
|
252
|
+
matchUnsigned,
|
|
253
|
+
match3,
|
|
254
|
+
addMillisecondsToInput()
|
|
255
|
+
],
|
|
256
|
+
s: [
|
|
257
|
+
match1to2,
|
|
258
|
+
match1to2,
|
|
259
|
+
addInput("seconds")
|
|
260
|
+
],
|
|
261
|
+
ss: [
|
|
262
|
+
match1to2,
|
|
263
|
+
match2,
|
|
264
|
+
addInput("seconds")
|
|
265
|
+
],
|
|
266
|
+
m: [
|
|
267
|
+
match1to2,
|
|
268
|
+
match1to2,
|
|
269
|
+
addInput("minutes")
|
|
270
|
+
],
|
|
271
|
+
mm: [
|
|
272
|
+
match1to2,
|
|
273
|
+
match2,
|
|
274
|
+
addInput("minutes")
|
|
275
|
+
],
|
|
276
|
+
H: [
|
|
277
|
+
match1to2,
|
|
278
|
+
match1to2,
|
|
279
|
+
addInput("hours")
|
|
280
|
+
],
|
|
281
|
+
HH: [
|
|
282
|
+
match1to2,
|
|
283
|
+
match2,
|
|
284
|
+
addInput("hours")
|
|
285
|
+
],
|
|
286
|
+
D: [
|
|
287
|
+
match1to2,
|
|
288
|
+
match1to2,
|
|
289
|
+
addInput("date")
|
|
290
|
+
],
|
|
291
|
+
DD: [
|
|
292
|
+
match1to2,
|
|
293
|
+
match2,
|
|
294
|
+
addInput("date")
|
|
295
|
+
],
|
|
296
|
+
x: [
|
|
297
|
+
matchSigned,
|
|
298
|
+
matchSigned,
|
|
299
|
+
(parsedElements, input) => {
|
|
300
|
+
parsedElements.unix = Number.parseInt(input, 10);
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
X: [
|
|
304
|
+
matchTimestamp,
|
|
305
|
+
matchTimestamp,
|
|
306
|
+
(parsedElements, input) => {
|
|
307
|
+
parsedElements.unix = Number.parseFloat(input) * 1e3;
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
M: [
|
|
311
|
+
match1to2,
|
|
312
|
+
match1to2,
|
|
313
|
+
addInput("month")
|
|
314
|
+
],
|
|
315
|
+
MM: [
|
|
316
|
+
match1to2,
|
|
317
|
+
match2,
|
|
318
|
+
addInput("month")
|
|
319
|
+
],
|
|
320
|
+
Y: [
|
|
321
|
+
matchSigned,
|
|
322
|
+
matchSigned,
|
|
323
|
+
(parsedElements, input) => {
|
|
324
|
+
parsedElements.year = Number.parseInt(input, 10);
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
YY: [
|
|
328
|
+
match1to4,
|
|
329
|
+
match2,
|
|
330
|
+
(parsedElements, input) => {
|
|
331
|
+
parsedElements.year = parseTwoDigitYear(input);
|
|
332
|
+
}
|
|
333
|
+
],
|
|
334
|
+
YYYY: [
|
|
335
|
+
match1to4,
|
|
336
|
+
match4,
|
|
337
|
+
(parsedElements, input) => {
|
|
338
|
+
parsedElements.year = parseFourDigitYear(input);
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
Z: [
|
|
342
|
+
matchOffset,
|
|
343
|
+
matchOffset,
|
|
344
|
+
(parsedElements, input) => {
|
|
345
|
+
parsedElements.zoneOffset = offsetFromString(input);
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
ZZ: [
|
|
349
|
+
matchOffset,
|
|
350
|
+
matchOffset,
|
|
351
|
+
(parsedElements, input) => {
|
|
352
|
+
parsedElements.zoneOffset = offsetFromString(input);
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
};
|
|
356
|
+
dayFactory.addParseTokenDefinitions(parseTokensDefinitions$1);
|
|
357
|
+
const oldParse = proto["$parse"];
|
|
358
|
+
proto["$parse"] = function(d) {
|
|
359
|
+
var _this$$conf;
|
|
360
|
+
const format = this["$conf"].args_1;
|
|
361
|
+
const arg2 = this["$conf"].args_2;
|
|
362
|
+
const arg3 = this["$conf"].args_3;
|
|
363
|
+
(_this$$conf = this["$conf"]).parseOptions ?? (_this$$conf.parseOptions = {});
|
|
364
|
+
const parseOptions = this["$conf"].parseOptions;
|
|
365
|
+
let isStrict = false;
|
|
366
|
+
if (typeof arg2 === "boolean") isStrict = arg2;
|
|
367
|
+
else if (arg3 !== void 0 && typeof arg3 === "boolean") isStrict = arg3;
|
|
368
|
+
if (isString(d) && !isUndefined(format)) {
|
|
369
|
+
if (isString(format)) {
|
|
370
|
+
const parsingResult = parseFormattedInput.call(this, d, format, isStrict, parseOptions);
|
|
371
|
+
this["$d"] = parsingResult.date;
|
|
372
|
+
if (isStrict && (parsingResult.charsLeftOver > 0 || parsingResult.unusedTokens > 0 || !parsingResult.separatorsMatch)) this["$d"] = invalidDate;
|
|
373
|
+
} else if (isArray(format)) {
|
|
374
|
+
let bestDate = invalidDate;
|
|
375
|
+
let scoreToBeat = 0;
|
|
376
|
+
let bestFormatIsValid = false;
|
|
377
|
+
for (let i = 0; i < format.length; i++) {
|
|
378
|
+
let currentScore = 0;
|
|
379
|
+
let validFormatFound = false;
|
|
380
|
+
const formatUnderInspection = format[i];
|
|
381
|
+
const parsingResult = parseFormattedInput.call(this, d, formatUnderInspection, isStrict, parseOptions);
|
|
382
|
+
if (isStrict && (parsingResult.charsLeftOver > 0 || parsingResult.unusedTokens > 0 || !parsingResult.separatorsMatch)) parsingResult.date = invalidDate;
|
|
383
|
+
if (isValidDate(parsingResult.date)) validFormatFound = true;
|
|
384
|
+
currentScore += parsingResult.charsLeftOver;
|
|
385
|
+
currentScore += parsingResult.unusedTokens * 10;
|
|
386
|
+
if (bestFormatIsValid) {
|
|
387
|
+
if (validFormatFound && !isUndefined(scoreToBeat) && currentScore < scoreToBeat) {
|
|
388
|
+
scoreToBeat = currentScore;
|
|
389
|
+
bestDate = parsingResult.date;
|
|
390
|
+
}
|
|
391
|
+
} else if (isUndefined(scoreToBeat) || currentScore < scoreToBeat || validFormatFound) {
|
|
392
|
+
scoreToBeat = currentScore;
|
|
393
|
+
bestDate = parsingResult.date;
|
|
394
|
+
if (validFormatFound) bestFormatIsValid = true;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
this["$d"] = bestDate;
|
|
398
|
+
}
|
|
399
|
+
} else oldParse.call(this, d);
|
|
400
|
+
};
|
|
401
|
+
dateFromDateComponents = proto["dateFromDateComponents"];
|
|
402
|
+
};
|
|
403
|
+
var advancedParse_default = advancedParsePlugin;
|
|
404
|
+
|
|
405
|
+
//#endregion
|
|
406
|
+
export { advancedParse_default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
import { CalendarPartial } from "../../chunks/St35qgL0.js";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/calendar/index.d.ts
|
|
6
|
+
|
|
7
|
+
declare module 'esday' {
|
|
8
|
+
interface EsDay {
|
|
9
|
+
calendar(referenceDate?: EsDay | null, formats?: CalendarPartial): string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare const calendarPlugin: EsDayPlugin<{}>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { calendarPlugin as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/plugins/calendar/index.ts
|
|
2
|
+
const defaultCalendar = {
|
|
3
|
+
sameDay: "[Today at] LT",
|
|
4
|
+
nextDay: "[Tomorrow at] LT",
|
|
5
|
+
nextWeek: "dddd [at] LT",
|
|
6
|
+
lastDay: "[Yesterday at] LT",
|
|
7
|
+
lastWeek: "[Last] dddd [at] LT",
|
|
8
|
+
sameElse: "L"
|
|
9
|
+
};
|
|
10
|
+
const calendarPlugin = (_, dayClass, dayFactory) => {
|
|
11
|
+
const proto = dayClass.prototype;
|
|
12
|
+
proto.calendar = function(referenceDate, formats) {
|
|
13
|
+
const format = formats ?? this.localeObject?.().calendar ?? defaultCalendar;
|
|
14
|
+
const referenceStartOfDay = dayFactory(referenceDate ?? void 0).startOf("date");
|
|
15
|
+
const diff = this.diff(referenceStartOfDay, "day", true);
|
|
16
|
+
const sameElse = "sameElse";
|
|
17
|
+
let retVal;
|
|
18
|
+
if (diff < -6) retVal = sameElse;
|
|
19
|
+
else if (diff < -1) retVal = "lastWeek";
|
|
20
|
+
else if (diff < 0) retVal = "lastDay";
|
|
21
|
+
else if (diff < 1) retVal = "sameDay";
|
|
22
|
+
else if (diff < 2) retVal = "nextDay";
|
|
23
|
+
else if (diff < 7) retVal = "nextWeek";
|
|
24
|
+
else retVal = sameElse;
|
|
25
|
+
let currentFormat = format[retVal] ?? defaultCalendar[retVal];
|
|
26
|
+
if (typeof currentFormat === "function") currentFormat = currentFormat.call(this, referenceStartOfDay);
|
|
27
|
+
return this.format(currentFormat);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var calendar_default = calendarPlugin;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { calendar_default as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/dayOfYear/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
dayOfYear(): number;
|
|
8
|
+
dayOfYear(dayOfYear: number): EsDay;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
declare const dayOfYearPlugin: EsDayPlugin<{}>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { dayOfYearPlugin as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/plugins/dayOfYear/index.ts
|
|
2
|
+
const SECONDS_A_DAY = 86400;
|
|
3
|
+
const dayOfYearPlugin = (_, dayClass, dayFactory) => {
|
|
4
|
+
dayClass.prototype.dayOfYear = function(input) {
|
|
5
|
+
const dayOfYear = Math.round((dayFactory(this).startOf("day").valueOf() - dayFactory(this).startOf("year").valueOf()) / SECONDS_A_DAY / 1e3) + 1;
|
|
6
|
+
return input === void 0 ? dayOfYear : this.add(input - dayOfYear, "day");
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
var dayOfYear_default = dayOfYearPlugin;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { dayOfYear_default as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DateType, EsDayPlugin, UnitType } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isBetween/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
/**
|
|
8
|
+
* returns a boolean indicating if a date is between two other dates
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const date = new EsDay('2021-01-01')
|
|
12
|
+
* date.isBetween('2020-01-01', '2022-01-01') // true
|
|
13
|
+
* date.isBetween('2021-01-01', '2022-01-01') // false
|
|
14
|
+
* date.isBetween('2020-01-01', '2022-01-01', 'date') // true
|
|
15
|
+
* date.isBetween('2020-01-01', '2022-01-01', 'date', '[]') // true
|
|
16
|
+
* date.isBetween('2020-01-01', '2022-01-01', 'date', '()') // false
|
|
17
|
+
*/
|
|
18
|
+
isBetween: (from: DateType, to: DateType, unit?: UnitType, inclusivity?: '()' | '[]' | '[)' | '(]') => boolean;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
declare const isBetweenPlugin: EsDayPlugin<{}>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { isBetweenPlugin as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { constants_default } from "../../chunks/Y32qdU_5.js";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/isBetween/index.ts
|
|
4
|
+
const isBetweenPlugin = (_, dayClass) => {
|
|
5
|
+
dayClass.prototype.isBetween = function(from, to, unit = constants_default.MS, inclusivity = "()") {
|
|
6
|
+
const includeFrom = inclusivity[0] === "[";
|
|
7
|
+
const includeTo = inclusivity[1] === "]";
|
|
8
|
+
const isAfterFrom = includeFrom ? !this.isBefore(from, unit) : this.isAfter(from, unit);
|
|
9
|
+
const isBeforeTo = includeTo ? !this.isAfter(to, unit) : this.isBefore(to, unit);
|
|
10
|
+
return isAfterFrom && isBeforeTo;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
var isBetween_default = isBetweenPlugin;
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isBetween_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isLeapYear/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isLeapYear: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const isLeapYearPlugin: EsDayPlugin<{}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isLeapYearPlugin as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/plugins/isLeapYear/index.ts
|
|
2
|
+
const isLeapYearPlugin = (_, dayClass) => {
|
|
3
|
+
dayClass.prototype.isLeapYear = function() {
|
|
4
|
+
const year = this.year();
|
|
5
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
var isLeapYear_default = isLeapYearPlugin;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isLeapYear_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DateType, EsDayPlugin, UnitType } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isSameOrAfter/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isSameOrAfter: (that: DateType, unit?: UnitType) => boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const isSameOrAfterPlugin: EsDayPlugin<{}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSameOrAfterPlugin as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/plugins/isSameOrAfter/index.ts
|
|
2
|
+
const isSameOrAfterPlugin = (_, dayClass) => {
|
|
3
|
+
dayClass.prototype.isSameOrAfter = function(that, unit) {
|
|
4
|
+
return this.isSame(that, unit) || this.isAfter(that, unit);
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
var isSameOrAfter_default = isSameOrAfterPlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isSameOrAfter_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DateType, EsDayPlugin, UnitType } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isSameOrBefore/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isSameOrBefore: (that: DateType, unit?: UnitType) => boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const isSameOrBeforePlugin: EsDayPlugin<{}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSameOrBeforePlugin as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/plugins/isSameOrBefore/index.ts
|
|
2
|
+
const isSameOrBeforePlugin = (_, dayClass) => {
|
|
3
|
+
dayClass.prototype.isSameOrBefore = function(that, unit) {
|
|
4
|
+
return this.isSame(that, unit) || this.isBefore(that, unit);
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
var isSameOrBefore_default = isSameOrBeforePlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isSameOrBefore_default as default };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
2
3
|
|
|
4
|
+
//#region src/plugins/isToday/index.d.ts
|
|
3
5
|
declare module 'esday' {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isToday: () => boolean;
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
declare const isTodayPlugin: EsDayPlugin<{}>;
|
|
9
|
-
|
|
10
|
-
export { isTodayPlugin };
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isTodayPlugin as default };
|
package/plugins/isToday/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { constants_default } from "../../chunks/Y32qdU_5.js";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/isToday/index.ts
|
|
4
|
+
const isTodayPlugin = (_, dayClass) => {
|
|
5
|
+
dayClass.prototype.isToday = function() {
|
|
6
|
+
return this.isSame(/* @__PURE__ */ new Date(), constants_default.DAY);
|
|
7
|
+
};
|
|
6
8
|
};
|
|
9
|
+
var isToday_default = isTodayPlugin;
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isToday_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isTomorrow/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isTomorrow: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const isTomorrowPlugin: EsDayPlugin<{}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isTomorrowPlugin as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { constants_default } from "../../chunks/Y32qdU_5.js";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/isTomorrow/index.ts
|
|
4
|
+
const isTomorrowPlugin = (_, dayClass, d) => {
|
|
5
|
+
dayClass.prototype.isTomorrow = function() {
|
|
6
|
+
const comparisonTemplate = "YYYY-MM-DD";
|
|
7
|
+
const tomorrow = d().add(1, constants_default.DAY);
|
|
8
|
+
return this.format(comparisonTemplate) === tomorrow.format(comparisonTemplate);
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
var isTomorrow_default = isTomorrowPlugin;
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { isTomorrow_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
|
|
2
|
+
import "../../chunks/MtjcOKi-.js";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/isYesterday/index.d.ts
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
isYesterday: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const isYesterdayPlugin: EsDayPlugin<{}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isYesterdayPlugin as default };
|