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,360 @@
|
|
|
1
|
+
import { constants_default } from "../../chunks/Y32qdU_5.js";
|
|
2
|
+
import { isArray, isObject, isUndefined } from "../../chunks/Cb5SvF6r.js";
|
|
3
|
+
import { normalizeUnitWithPlurals } from "../../chunks/DjY7KvwG.js";
|
|
4
|
+
import { createInstanceFromExist } from "../../chunks/DXHbH1CI.js";
|
|
5
|
+
import { padStart } from "../../chunks/BRRrAbUl.js";
|
|
6
|
+
|
|
7
|
+
//#region src/plugins/week/index.ts
|
|
8
|
+
const match1to2NoLeadingZero = /^[1-9]\d?/;
|
|
9
|
+
const match1 = /\d/;
|
|
10
|
+
const match2 = /\d\d/;
|
|
11
|
+
const match1to2 = /\d\d?/;
|
|
12
|
+
const match4 = /\d{4}/;
|
|
13
|
+
const match1to4 = /\d{1,4}/;
|
|
14
|
+
const matchWord = /\d*[^-_:/,()\s\d]+/;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a number to an ordinal number, if a locale is available.
|
|
17
|
+
* Otherwise return value as string.
|
|
18
|
+
* @param sourceDate - date to take the locale from
|
|
19
|
+
* @param value - value to convert
|
|
20
|
+
* @returns value as ordinal
|
|
21
|
+
*/
|
|
22
|
+
function toOrdinal(sourceDate, value) {
|
|
23
|
+
const defaultValue = value.toString();
|
|
24
|
+
return sourceDate.localeObject?.().ordinal?.(value) ?? defaultValue;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a function that will parse the input string as week, weekday or
|
|
28
|
+
* weekYear number and add it to the given 'parsedElements' containing the
|
|
29
|
+
* date&time components.
|
|
30
|
+
* @param property - name of the property to set
|
|
31
|
+
* @returns function that will add the given value to date&time component as new element
|
|
32
|
+
*/
|
|
33
|
+
function addWeek(property) {
|
|
34
|
+
return function weekPropUpdater(parsedElements, input, _parseOptions) {
|
|
35
|
+
parsedElements[property] = +input;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a function that will convert the value from the input string
|
|
40
|
+
* to a day of week number and add it to the given 'parsedElements'
|
|
41
|
+
* containing the date&time components.
|
|
42
|
+
* @param property - name of the list of weekday names to use
|
|
43
|
+
* @returns function that will add the weekday value to date&time component
|
|
44
|
+
*/
|
|
45
|
+
function addDayOfWeek(property, esday) {
|
|
46
|
+
return function weekdayUpdater(parsedElements, input, parseOptions) {
|
|
47
|
+
if (property === "day") parsedElements[property] = +input;
|
|
48
|
+
else {
|
|
49
|
+
const localeName = parseOptions["locale"];
|
|
50
|
+
const weekdays = esday.getLocale(localeName)[property];
|
|
51
|
+
let weekdayNames;
|
|
52
|
+
if (isArray(weekdays)) weekdayNames = weekdays;
|
|
53
|
+
else weekdayNames = weekdays.standalone;
|
|
54
|
+
parsedElements.day = weekdayNames.indexOf(input);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function parseTwoDigitYear(input) {
|
|
59
|
+
const inputLimited = input.slice(0, 2);
|
|
60
|
+
const year = +inputLimited;
|
|
61
|
+
return year + (year > 68 ? 1900 : 2e3);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Add parsed year as 2-digit value to parsedElements
|
|
65
|
+
* @param parsedElements - object containing the components of a parsed date
|
|
66
|
+
* @param input - parsed value (year)
|
|
67
|
+
* @param _options - parsing options e.g. containing the locale to use
|
|
68
|
+
*/
|
|
69
|
+
function twoDigitsYearUpdater(parsedElements, input, _parseOptions) {
|
|
70
|
+
parsedElements["weekYear"] = parseTwoDigitYear(input);
|
|
71
|
+
}
|
|
72
|
+
const weekPlugin = (_, dayClass, dayFactory) => {
|
|
73
|
+
const proto = dayClass.prototype;
|
|
74
|
+
/**
|
|
75
|
+
* Set the week of the parsed date.
|
|
76
|
+
* Must be called in the context of an EsDay instance.
|
|
77
|
+
* @param this - context for this function (required for getting the $conf settings)
|
|
78
|
+
* @param parsedDate - Date object returned by parsing function
|
|
79
|
+
* @param parsedElements - object containing the components of a parsed date
|
|
80
|
+
* @returns parsedDate with week set to parsed value
|
|
81
|
+
*/
|
|
82
|
+
function _postParseWeek(parsedDate, parsedElements) {
|
|
83
|
+
let modifiedDate = parsedDate;
|
|
84
|
+
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(parsedElements.week)) && isUndefined(parsedElements.date)) {
|
|
85
|
+
const newEsday = createInstanceFromExist(parsedDate, this);
|
|
86
|
+
const parsedWeek = parsedElements.week;
|
|
87
|
+
const modifiedEsday = newEsday.week(parsedWeek).weekday(0);
|
|
88
|
+
modifiedDate = modifiedEsday.toDate();
|
|
89
|
+
}
|
|
90
|
+
return modifiedDate;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Set the dayOfWeek of the parsed date.
|
|
94
|
+
* Must be called in the context of an EsDay instance.
|
|
95
|
+
* @param this - context for this function (required for getting the $conf settings)
|
|
96
|
+
* @param parsedDate - Date object returned by parsing function
|
|
97
|
+
* @param parsedElements - object containing the components of a parsed date
|
|
98
|
+
* @returns parsedDate or invalid date (if day of week does not match)
|
|
99
|
+
*/
|
|
100
|
+
function _postParseWeekDay(parsedDate, parsedElements) {
|
|
101
|
+
const newWeekday = parsedElements.weekday;
|
|
102
|
+
if (!isUndefined(newWeekday) && newWeekday !== null && (newWeekday < 0 || newWeekday > 6)) return constants_default.INVALID_DATE;
|
|
103
|
+
let modifiedDate = parsedDate;
|
|
104
|
+
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(newWeekday)) && isUndefined(parsedElements.date)) {
|
|
105
|
+
let newEsday = dayFactory(parsedDate, { utc: this["$conf"].utc });
|
|
106
|
+
newEsday["$conf"] = structuredClone(this["$conf"]);
|
|
107
|
+
if (isUndefined(parsedElements.weekYear) && isUndefined(parsedElements.week)) {
|
|
108
|
+
const now = /* @__PURE__ */ new Date();
|
|
109
|
+
newEsday = newEsday.month(now.getMonth()).date(now.getDate());
|
|
110
|
+
}
|
|
111
|
+
const modifiedEsday = newEsday.weekday(newWeekday);
|
|
112
|
+
modifiedDate = modifiedEsday.toDate();
|
|
113
|
+
}
|
|
114
|
+
return modifiedDate;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Verify that parsed date is the expected day-of-week or set the day-of-week.
|
|
118
|
+
* Must be called in the context of an EsDay instance.
|
|
119
|
+
* @param this - context for this function (required for getting the $conf settings)
|
|
120
|
+
* @param parsedDate - Date object returned by parsing function
|
|
121
|
+
* @param parsedElements - object containing the components of a parsed date
|
|
122
|
+
* @returns parsedDate or invalid date (if day of week does not match)
|
|
123
|
+
*/
|
|
124
|
+
function _postParseDayOfWeek(parsedDate, parsedElements) {
|
|
125
|
+
let modifiedDate = parsedDate;
|
|
126
|
+
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(parsedElements.day))) {
|
|
127
|
+
const now = createInstanceFromExist(/* @__PURE__ */ new Date(), this);
|
|
128
|
+
let newEsday = createInstanceFromExist(parsedDate, this);
|
|
129
|
+
if (parsedElements.year !== void 0 && parsedElements.month === void 0 && parsedElements.date === void 0) {
|
|
130
|
+
const currentWeek = now.week();
|
|
131
|
+
const dayOfWeek = (parsedElements.day + 7 - newEsday.localeObject().weekStart) % 7;
|
|
132
|
+
newEsday = newEsday.week(currentWeek).weekday(dayOfWeek);
|
|
133
|
+
modifiedDate = newEsday.toDate();
|
|
134
|
+
}
|
|
135
|
+
if (newEsday.day() !== parsedElements.day) modifiedDate = constants_default.INVALID_DATE;
|
|
136
|
+
}
|
|
137
|
+
return modifiedDate;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Set weekYear of parsed date.
|
|
141
|
+
* Must be called in the context of an EsDay instance.
|
|
142
|
+
* @param this - context for this function (required for getting the $conf settings)
|
|
143
|
+
* @param parsedDate - Date object returned by parsing function
|
|
144
|
+
* @param parsedElements - object containing the components of a parsed date
|
|
145
|
+
* @returns parsedDate with weekYear set to parsed value
|
|
146
|
+
*/
|
|
147
|
+
function _postParseYear(parsedDate, parsedElements) {
|
|
148
|
+
let modifiedDate = parsedDate;
|
|
149
|
+
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(parsedElements.weekYear))) {
|
|
150
|
+
const newEsday = createInstanceFromExist(parsedDate, this);
|
|
151
|
+
const parsedWeekYear = parsedElements.weekYear;
|
|
152
|
+
if (Object.keys(parsedElements).length === 1) {
|
|
153
|
+
const now = /* @__PURE__ */ new Date();
|
|
154
|
+
let modifiedEsday = newEsday.weekYear(parsedWeekYear);
|
|
155
|
+
modifiedEsday = modifiedEsday.year(parsedWeekYear).month(now.getMonth()).date(now.getDate()).weekday(0);
|
|
156
|
+
modifiedDate = modifiedEsday.toDate();
|
|
157
|
+
} else if (!isUndefined(parsedElements.week)) {
|
|
158
|
+
const modifiedEsday = newEsday.weekYear(parsedWeekYear);
|
|
159
|
+
modifiedDate = modifiedEsday.toDate();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return modifiedDate;
|
|
163
|
+
}
|
|
164
|
+
proto.week = function(newWeek) {
|
|
165
|
+
if (newWeek !== void 0) {
|
|
166
|
+
const currentWeekday = this.weekday();
|
|
167
|
+
const h = this.hour();
|
|
168
|
+
const m = this.minute();
|
|
169
|
+
const s = this.second();
|
|
170
|
+
const ms = this.millisecond();
|
|
171
|
+
return this.add((newWeek - this.week()) * 7, constants_default.DAY).weekday(currentWeekday).hour(h, m, s, ms);
|
|
172
|
+
}
|
|
173
|
+
const yearStart = this.localeObject?.().yearStart || constants_default.INDEX_THURSDAY;
|
|
174
|
+
if (this.month() === 11 && this.date() > 25) {
|
|
175
|
+
const nextYearStartDay = this.startOf(constants_default.YEAR).add(1, constants_default.YEAR).date(yearStart);
|
|
176
|
+
const thisEndOfWeek = this.endOf(constants_default.WEEK);
|
|
177
|
+
if (nextYearStartDay.isBefore(thisEndOfWeek)) return 1;
|
|
178
|
+
}
|
|
179
|
+
const yearStartDay = this.startOf(constants_default.YEAR).date(yearStart);
|
|
180
|
+
const yearStartWeek = yearStartDay.startOf(constants_default.WEEK).subtract(1, constants_default.MS);
|
|
181
|
+
const diffInWeek = this.diff(yearStartWeek, constants_default.WEEK, true);
|
|
182
|
+
if (diffInWeek < 0) return this.startOf(constants_default.WEEK).week();
|
|
183
|
+
return Math.ceil(diffInWeek);
|
|
184
|
+
};
|
|
185
|
+
proto.weeks = proto.week;
|
|
186
|
+
/**
|
|
187
|
+
* Get or set the locale aware day of the week.
|
|
188
|
+
* 0 is always the first day of the week (according to locale.weekStart property),
|
|
189
|
+
* 6 is always the last day of the week.
|
|
190
|
+
* E.g. in Europe 0=Monday ... 6=Sunday.
|
|
191
|
+
* If no locale is loaded, Monday is used as start of week.
|
|
192
|
+
*/
|
|
193
|
+
dayClass.prototype.weekday = function(newWeekday) {
|
|
194
|
+
const weekStart = this.localeObject?.().weekStart ?? constants_default.INDEX_MONDAY;
|
|
195
|
+
const dow = this.day();
|
|
196
|
+
const weekday = (dow < weekStart ? dow + 7 : dow) - weekStart;
|
|
197
|
+
if (newWeekday !== void 0) return this.subtract(weekday, constants_default.DAY).add(newWeekday, constants_default.DAY);
|
|
198
|
+
return weekday;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Gets or sets the year of the week. This year may differ from
|
|
202
|
+
* the calendar year at the start or the end of a year (depending on
|
|
203
|
+
* 'yearStart').
|
|
204
|
+
* Setting the weekYear will keep the week number and the day of the week.
|
|
205
|
+
* If no locale is loaded, Monday is used as start of week.
|
|
206
|
+
*/
|
|
207
|
+
proto.weekYear = function(newWeekYear) {
|
|
208
|
+
if (newWeekYear !== void 0) {
|
|
209
|
+
if (this.weekYear() === newWeekYear) return this;
|
|
210
|
+
const currentWeek = this.week();
|
|
211
|
+
const currentWeekday = this.weekday();
|
|
212
|
+
let newDate = this.year(newWeekYear).week(currentWeek).weekday(currentWeekday);
|
|
213
|
+
if (newDate.weekYear() !== newWeekYear) {
|
|
214
|
+
const yearDiff = newWeekYear - newDate.weekYear();
|
|
215
|
+
newDate = newDate.add(yearDiff, constants_default.YEAR).weekday(currentWeekday);
|
|
216
|
+
}
|
|
217
|
+
return newDate;
|
|
218
|
+
}
|
|
219
|
+
const month = this.month();
|
|
220
|
+
const weekOfYear = this.week();
|
|
221
|
+
const year = this.year();
|
|
222
|
+
if (weekOfYear === 1 && month === 11) return year + 1;
|
|
223
|
+
if (month === 0 && weekOfYear >= 52) return year - 1;
|
|
224
|
+
return year;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Get the number of weeks in the current year.
|
|
228
|
+
* Most years have 52 weeks, some have 53 weeks.
|
|
229
|
+
*/
|
|
230
|
+
proto.weeksInYear = function() {
|
|
231
|
+
const weekStart = this.localeObject?.().weekStart ?? constants_default.INDEX_MONDAY;
|
|
232
|
+
const yearStart = this.localeObject?.().yearStart ?? constants_default.INDEX_THURSDAY;
|
|
233
|
+
const preWeekStart = ((weekStart + 6) % 7 + 8 - yearStart) % 7;
|
|
234
|
+
const prePreWeekStart = (preWeekStart + 6) % 7;
|
|
235
|
+
const yearStartWeekday = this.month(0).date(1).day();
|
|
236
|
+
const year = this.year();
|
|
237
|
+
const isLeapYear = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
238
|
+
if (yearStartWeekday === preWeekStart || isLeapYear && yearStartWeekday === prePreWeekStart) return 53;
|
|
239
|
+
return 52;
|
|
240
|
+
};
|
|
241
|
+
const oldStartOf = proto.startOf;
|
|
242
|
+
proto.startOf = function(units) {
|
|
243
|
+
if (units === constants_default.WEEK) {
|
|
244
|
+
let newDate = this.clone();
|
|
245
|
+
const weekStart = newDate.localeObject?.().weekStart ?? constants_default.INDEX_MONDAY;
|
|
246
|
+
const newDateWeekday = newDate.day();
|
|
247
|
+
const diff = (newDateWeekday < weekStart ? newDateWeekday + 7 : newDateWeekday) - weekStart;
|
|
248
|
+
const newDayOfMonth = newDate.date() - diff;
|
|
249
|
+
newDate = newDate.date(newDayOfMonth);
|
|
250
|
+
return newDate["$set"](constants_default.HOUR, [
|
|
251
|
+
0,
|
|
252
|
+
0,
|
|
253
|
+
0,
|
|
254
|
+
0
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
return oldStartOf.call(this, units);
|
|
258
|
+
};
|
|
259
|
+
const oldEndOf = proto.endOf;
|
|
260
|
+
proto.endOf = function(units) {
|
|
261
|
+
if (units === constants_default.WEEK) {
|
|
262
|
+
let newDate = this.clone();
|
|
263
|
+
const weekStart = newDate.localeObject?.().weekStart ?? constants_default.INDEX_MONDAY;
|
|
264
|
+
const newDateWeekday = newDate.day();
|
|
265
|
+
const diff = (newDateWeekday < weekStart ? newDateWeekday + 7 : newDateWeekday) - weekStart;
|
|
266
|
+
const newDayOfMonth = newDate.date() + (6 - diff);
|
|
267
|
+
newDate = newDate.date(newDayOfMonth);
|
|
268
|
+
return newDate["$set"](constants_default.HOUR, [
|
|
269
|
+
23,
|
|
270
|
+
59,
|
|
271
|
+
59,
|
|
272
|
+
999
|
|
273
|
+
]);
|
|
274
|
+
}
|
|
275
|
+
return oldEndOf.call(this, units);
|
|
276
|
+
};
|
|
277
|
+
const oldGet = proto.get;
|
|
278
|
+
proto.get = function(unit) {
|
|
279
|
+
const normalizedUnit = normalizeUnitWithPlurals(unit);
|
|
280
|
+
if (normalizedUnit === constants_default.WEEK) return this.week();
|
|
281
|
+
return oldGet.call(this, unit);
|
|
282
|
+
};
|
|
283
|
+
const old$set = proto["$set"];
|
|
284
|
+
proto["$set"] = function(unit, values) {
|
|
285
|
+
if (isObject(unit)) return this.clone();
|
|
286
|
+
const normalizedUnit = normalizeUnitWithPlurals(unit);
|
|
287
|
+
if (normalizedUnit === constants_default.WEEK) return this.week(values[0]);
|
|
288
|
+
return old$set.call(this, unit, values);
|
|
289
|
+
};
|
|
290
|
+
const additionalTokens = {
|
|
291
|
+
w: (sourceDate) => sourceDate.week().toString(),
|
|
292
|
+
ww: (sourceDate) => padStart(sourceDate.week(), 2, "0"),
|
|
293
|
+
wo: (sourceDate) => toOrdinal(sourceDate, sourceDate.week()),
|
|
294
|
+
e: (sourceDate) => sourceDate.weekday().toString(),
|
|
295
|
+
gg: (sourceDate) => padStart(sourceDate.weekYear(), 2, "0").slice(-2),
|
|
296
|
+
gggg: (sourceDate) => padStart(sourceDate.weekYear(), 4, "0")
|
|
297
|
+
};
|
|
298
|
+
dayFactory.addFormatTokenDefinitions(additionalTokens);
|
|
299
|
+
const parseTokensDefinitions = {
|
|
300
|
+
d: [
|
|
301
|
+
match1to2,
|
|
302
|
+
match1to2,
|
|
303
|
+
addDayOfWeek("day", dayFactory),
|
|
304
|
+
_postParseDayOfWeek
|
|
305
|
+
],
|
|
306
|
+
dd: [
|
|
307
|
+
matchWord,
|
|
308
|
+
matchWord,
|
|
309
|
+
addDayOfWeek("weekdaysMin", dayFactory),
|
|
310
|
+
_postParseDayOfWeek
|
|
311
|
+
],
|
|
312
|
+
ddd: [
|
|
313
|
+
matchWord,
|
|
314
|
+
matchWord,
|
|
315
|
+
addDayOfWeek("weekdaysShort", dayFactory),
|
|
316
|
+
_postParseDayOfWeek
|
|
317
|
+
],
|
|
318
|
+
dddd: [
|
|
319
|
+
matchWord,
|
|
320
|
+
matchWord,
|
|
321
|
+
addDayOfWeek("weekdays", dayFactory),
|
|
322
|
+
_postParseDayOfWeek
|
|
323
|
+
],
|
|
324
|
+
w: [
|
|
325
|
+
match1to2,
|
|
326
|
+
match1to2NoLeadingZero,
|
|
327
|
+
addWeek("week"),
|
|
328
|
+
_postParseWeek
|
|
329
|
+
],
|
|
330
|
+
ww: [
|
|
331
|
+
match1to2,
|
|
332
|
+
match2,
|
|
333
|
+
addWeek("week"),
|
|
334
|
+
_postParseWeek
|
|
335
|
+
],
|
|
336
|
+
e: [
|
|
337
|
+
match1to2,
|
|
338
|
+
match1,
|
|
339
|
+
addWeek("weekday"),
|
|
340
|
+
_postParseWeekDay
|
|
341
|
+
],
|
|
342
|
+
gg: [
|
|
343
|
+
match1to4,
|
|
344
|
+
match2,
|
|
345
|
+
twoDigitsYearUpdater,
|
|
346
|
+
_postParseYear
|
|
347
|
+
],
|
|
348
|
+
gggg: [
|
|
349
|
+
match1to4,
|
|
350
|
+
match4,
|
|
351
|
+
addWeek("weekYear"),
|
|
352
|
+
_postParseYear
|
|
353
|
+
]
|
|
354
|
+
};
|
|
355
|
+
dayFactory.addParseTokenDefinitions?.(parseTokensDefinitions);
|
|
356
|
+
};
|
|
357
|
+
var week_default = weekPlugin;
|
|
358
|
+
|
|
359
|
+
//#endregion
|
|
360
|
+
export { week_default as default };
|
package/EsDay-KXQgnL1r.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
declare const UNIT_MAP: {
|
|
2
|
-
readonly y: "year";
|
|
3
|
-
readonly M: "month";
|
|
4
|
-
readonly D: "date";
|
|
5
|
-
readonly d: "day";
|
|
6
|
-
readonly h: "hour";
|
|
7
|
-
readonly m: "minute";
|
|
8
|
-
readonly s: "second";
|
|
9
|
-
readonly ms: "millisecond";
|
|
10
|
-
readonly w: "week";
|
|
11
|
-
};
|
|
12
|
-
type ShortUnit = keyof typeof UNIT_MAP;
|
|
13
|
-
type PrettyUnitType = typeof UNIT_MAP[ShortUnit];
|
|
14
|
-
type UnitType = ShortUnit | PrettyUnitType;
|
|
15
|
-
type PrettyUnit<T extends UnitType> = T extends ShortUnit ? typeof UNIT_MAP[T] : T;
|
|
16
|
-
type UnionUnit<T extends ShortUnit> = T | PrettyUnit<T>;
|
|
17
|
-
type UnitYear = UnionUnit<'y'>;
|
|
18
|
-
type UnitMonth = UnionUnit<'M'>;
|
|
19
|
-
type UnitDate = UnionUnit<'D'>;
|
|
20
|
-
type UnitDay = UnionUnit<'d'>;
|
|
21
|
-
type UnitHour = UnionUnit<'h'>;
|
|
22
|
-
type UnitMin = UnionUnit<'m'>;
|
|
23
|
-
type UnitSecond = UnionUnit<'s'>;
|
|
24
|
-
type UnitMs = UnionUnit<'ms'>;
|
|
25
|
-
type UnitWeek = UnionUnit<'w'>;
|
|
26
|
-
|
|
27
|
-
type SimpleType = string | number | boolean | null | undefined;
|
|
28
|
-
type SimpleObject = Record<string, SimpleType>;
|
|
29
|
-
|
|
30
|
-
type EsDayFactoryParserFn = (d?: DateType, ...others: (SimpleType | {
|
|
31
|
-
[key: string]: SimpleType;
|
|
32
|
-
})[]) => EsDay;
|
|
33
|
-
interface EsDayFactory {
|
|
34
|
-
(...args: Parameters<EsDayFactoryParserFn>): ReturnType<EsDayFactoryParserFn>;
|
|
35
|
-
extend: <T extends {}>(plugin: EsDayPlugin<T>, option?: T) => EsDayFactory;
|
|
36
|
-
}
|
|
37
|
-
type EsDayPlugin<T extends {}> = (option: T, dayTsClass: typeof EsDay, esday: EsDayFactory) => void;
|
|
38
|
-
type DateType = EsDay | Date | string | number | number[] | null | undefined | object;
|
|
39
|
-
|
|
40
|
-
declare interface EsDay {
|
|
41
|
-
year: (() => number) & ((year: number, month?: number, date?: number) => EsDay);
|
|
42
|
-
month: (() => number) & ((month: number, date?: number) => EsDay);
|
|
43
|
-
date: (() => number) & ((date: number) => EsDay);
|
|
44
|
-
day: (() => number) & ((day: number) => EsDay);
|
|
45
|
-
hour: (() => number) & ((hours: number, min?: number, sec?: number, ms?: number) => EsDay);
|
|
46
|
-
minute: (() => number) & ((min: number, sec?: number, ms?: number) => EsDay);
|
|
47
|
-
second: (() => number) & ((sec: number, ms?: number) => EsDay);
|
|
48
|
-
millisecond: (() => number) & ((ms: number) => EsDay);
|
|
49
|
-
}
|
|
50
|
-
declare class EsDay {
|
|
51
|
-
private $d;
|
|
52
|
-
/**
|
|
53
|
-
* mainly for plugin compatibility
|
|
54
|
-
* store data such as locale name, utc mode, etc.
|
|
55
|
-
*/
|
|
56
|
-
private $conf;
|
|
57
|
-
constructor(d: Exclude<DateType, EsDay>, conf?: SimpleObject);
|
|
58
|
-
private parse;
|
|
59
|
-
private $parseDate;
|
|
60
|
-
isSame(that: DateType, units?: UnitType): boolean;
|
|
61
|
-
isAfter(that: DateType, units?: UnitType): boolean;
|
|
62
|
-
isBefore(that: DateType, units?: UnitType): boolean;
|
|
63
|
-
valueOf(): number;
|
|
64
|
-
unix(): number;
|
|
65
|
-
isValid(): boolean;
|
|
66
|
-
clone(): EsDay;
|
|
67
|
-
format(formatStr?: string): string;
|
|
68
|
-
utcOffset(): number;
|
|
69
|
-
startOf(units: UnitType): EsDay;
|
|
70
|
-
endOf(units: UnitType): EsDay;
|
|
71
|
-
add(number: number, units: UnitType): EsDay;
|
|
72
|
-
subtract(number: number, units: UnitType): EsDay;
|
|
73
|
-
get(units: Exclude<UnitType, UnitWeek>): number;
|
|
74
|
-
set(unit: UnitYear, year: number, month?: number, date?: number): EsDay;
|
|
75
|
-
set(unit: UnitMonth, month: number, date?: number): EsDay;
|
|
76
|
-
set(unit: UnitDate, date: number): EsDay;
|
|
77
|
-
set(unit: UnitDay, day: number): EsDay;
|
|
78
|
-
set(unit: UnitHour, hours: number, min?: number, sec?: number, ms?: number): EsDay;
|
|
79
|
-
set(unit: UnitMin, min: number, sec?: number, ms?: number): EsDay;
|
|
80
|
-
set(unit: UnitSecond, sec: number, ms?: number): EsDay;
|
|
81
|
-
set(unit: UnitMs, ms: number): EsDay;
|
|
82
|
-
toDate(): Date;
|
|
83
|
-
toJSON(): string | null;
|
|
84
|
-
toISOString(): string;
|
|
85
|
-
toString(): string;
|
|
86
|
-
private $set;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { type DateType as D, type EsDayFactory as E, type PrettyUnit as P, type UnitType as U, EsDay as a, type PrettyUnitType as b, type EsDayFactoryParserFn as c, type EsDayPlugin as d };
|
package/chunk-MLKGABMK.js
DELETED
package/chunk-NUV73YDM.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// src/locales/en.ts
|
|
2
|
-
var localeEn = {
|
|
3
|
-
name: "en",
|
|
4
|
-
weekdays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
5
|
-
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
6
|
-
weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
7
|
-
weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
8
|
-
monthsShort: [
|
|
9
|
-
"Jan",
|
|
10
|
-
"Feb",
|
|
11
|
-
"Mar",
|
|
12
|
-
"Apr",
|
|
13
|
-
"May",
|
|
14
|
-
"Jun",
|
|
15
|
-
"Jul",
|
|
16
|
-
"Aug",
|
|
17
|
-
"Sep",
|
|
18
|
-
"Oct",
|
|
19
|
-
"Nov",
|
|
20
|
-
"Dec"
|
|
21
|
-
],
|
|
22
|
-
weekStart: 1,
|
|
23
|
-
yearStart: 4,
|
|
24
|
-
formats: {
|
|
25
|
-
LT: "HH:mm",
|
|
26
|
-
LTS: "HH:mm:ss",
|
|
27
|
-
L: "DD/MM/YYYY",
|
|
28
|
-
LL: "D MMMM YYYY",
|
|
29
|
-
LLL: "D MMMM YYYY HH:mm",
|
|
30
|
-
LLLL: "dddd, D MMMM YYYY HH:mm"
|
|
31
|
-
},
|
|
32
|
-
relativeTime: {
|
|
33
|
-
future: "in %s",
|
|
34
|
-
past: "%s ago",
|
|
35
|
-
s: "a few seconds",
|
|
36
|
-
m: "a minute",
|
|
37
|
-
mm: "%d minutes",
|
|
38
|
-
h: "an hour",
|
|
39
|
-
hh: "%d hours",
|
|
40
|
-
d: "a day",
|
|
41
|
-
dd: "%d days",
|
|
42
|
-
M: "a month",
|
|
43
|
-
MM: "%d months",
|
|
44
|
-
y: "a year",
|
|
45
|
-
yy: "%d years"
|
|
46
|
-
},
|
|
47
|
-
meridiem: (hour, minute, isLowercase) => {
|
|
48
|
-
const m = hour < 12 ? "AM" : "PM";
|
|
49
|
-
return isLowercase ? m.toLowerCase() : m;
|
|
50
|
-
},
|
|
51
|
-
ordinal: (n) => {
|
|
52
|
-
const s = ["th", "st", "nd", "rd"];
|
|
53
|
-
const v = n % 100;
|
|
54
|
-
return `[${n}${s[(v - 20) % 10] || s[v] || s[0]}]`;
|
|
55
|
-
},
|
|
56
|
-
invalidDate: "Invalid date"
|
|
57
|
-
};
|
|
58
|
-
var en_default = localeEn;
|
|
59
|
-
|
|
60
|
-
export { en_default };
|
package/chunk-SQBPUYUY.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { __export } from './chunk-MLKGABMK.js';
|
|
2
|
-
|
|
3
|
-
// src/common/constant.ts
|
|
4
|
-
var constant_exports = {};
|
|
5
|
-
__export(constant_exports, {
|
|
6
|
-
DATE: () => DATE,
|
|
7
|
-
DAY: () => DAY,
|
|
8
|
-
FORMAT_DEFAULT: () => FORMAT_DEFAULT,
|
|
9
|
-
HOUR: () => HOUR,
|
|
10
|
-
INDEX_MONDAY: () => INDEX_MONDAY,
|
|
11
|
-
INVALID_DATE_STRING: () => INVALID_DATE_STRING,
|
|
12
|
-
MILLISECONDS_A_DAY: () => MILLISECONDS_A_DAY,
|
|
13
|
-
MILLISECONDS_A_HOUR: () => MILLISECONDS_A_HOUR,
|
|
14
|
-
MILLISECONDS_A_MINUTE: () => MILLISECONDS_A_MINUTE,
|
|
15
|
-
MILLISECONDS_A_SECOND: () => MILLISECONDS_A_SECOND,
|
|
16
|
-
MILLISECONDS_A_WEEK: () => MILLISECONDS_A_WEEK,
|
|
17
|
-
MIN: () => MIN,
|
|
18
|
-
MONTH: () => MONTH,
|
|
19
|
-
MS: () => MS,
|
|
20
|
-
REGEX_FORMAT: () => REGEX_FORMAT,
|
|
21
|
-
REGEX_PARSE: () => REGEX_PARSE,
|
|
22
|
-
SECOND: () => SECOND,
|
|
23
|
-
SECONDS_A_DAY: () => SECONDS_A_DAY,
|
|
24
|
-
SECONDS_A_HOUR: () => SECONDS_A_HOUR,
|
|
25
|
-
SECONDS_A_MINUTE: () => SECONDS_A_MINUTE,
|
|
26
|
-
SECONDS_A_WEEK: () => SECONDS_A_WEEK,
|
|
27
|
-
WEEK: () => WEEK,
|
|
28
|
-
YEAR: () => YEAR
|
|
29
|
-
});
|
|
30
|
-
var SECONDS_A_MINUTE = 60;
|
|
31
|
-
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
|
|
32
|
-
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
|
|
33
|
-
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
|
|
34
|
-
var MILLISECONDS_A_SECOND = 1e3;
|
|
35
|
-
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
|
|
36
|
-
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
|
|
37
|
-
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
|
|
38
|
-
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
|
|
39
|
-
var INDEX_MONDAY = 1;
|
|
40
|
-
var MS = "millisecond";
|
|
41
|
-
var SECOND = "second";
|
|
42
|
-
var MIN = "minute";
|
|
43
|
-
var HOUR = "hour";
|
|
44
|
-
var DAY = "day";
|
|
45
|
-
var WEEK = "week";
|
|
46
|
-
var MONTH = "month";
|
|
47
|
-
var YEAR = "year";
|
|
48
|
-
var DATE = "date";
|
|
49
|
-
var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
|
|
50
|
-
var INVALID_DATE_STRING = "Invalid Date";
|
|
51
|
-
var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
|
52
|
-
var REGEX_FORMAT = /\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
53
|
-
|
|
54
|
-
// src/common/is.ts
|
|
55
|
-
function isUndefined(value) {
|
|
56
|
-
return value === void 0;
|
|
57
|
-
}
|
|
58
|
-
function undefinedOr(v, or) {
|
|
59
|
-
return isUndefined(v) ? or : v;
|
|
60
|
-
}
|
|
61
|
-
function isObject(value) {
|
|
62
|
-
return typeof value === "object" && value !== null;
|
|
63
|
-
}
|
|
64
|
-
function isEmptyObject(value) {
|
|
65
|
-
return isObject(value) && Object.keys(value).length === 0;
|
|
66
|
-
}
|
|
67
|
-
function isString(value) {
|
|
68
|
-
return typeof value === "string";
|
|
69
|
-
}
|
|
70
|
-
function isArray(value) {
|
|
71
|
-
return Array.isArray(value);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/common/unit.ts
|
|
75
|
-
var UNIT_MAP = {
|
|
76
|
-
y: YEAR,
|
|
77
|
-
M: MONTH,
|
|
78
|
-
D: DATE,
|
|
79
|
-
d: DAY,
|
|
80
|
-
h: HOUR,
|
|
81
|
-
m: MIN,
|
|
82
|
-
s: SECOND,
|
|
83
|
-
ms: MS,
|
|
84
|
-
w: WEEK
|
|
85
|
-
};
|
|
86
|
-
function prettyUnit(u) {
|
|
87
|
-
const maybePrettyUnit = UNIT_MAP[u];
|
|
88
|
-
return maybePrettyUnit || u;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// src/common/date-fields.ts
|
|
92
|
-
var UNIT_FIELD_MAP = {
|
|
93
|
-
year: "FullYear",
|
|
94
|
-
month: "Month",
|
|
95
|
-
date: "Date",
|
|
96
|
-
day: "Day",
|
|
97
|
-
hour: "Hours",
|
|
98
|
-
minute: "Minutes",
|
|
99
|
-
second: "Seconds",
|
|
100
|
-
millisecond: "Milliseconds"
|
|
101
|
-
};
|
|
102
|
-
function unitToField(unit) {
|
|
103
|
-
const p = prettyUnit(unit);
|
|
104
|
-
return UNIT_FIELD_MAP[p];
|
|
105
|
-
}
|
|
106
|
-
function getUnitInDate(date, unit, utc) {
|
|
107
|
-
const field = unitToField(unit);
|
|
108
|
-
const method = `get${utc ? "UTC" : ""}${field}`;
|
|
109
|
-
return date[method]();
|
|
110
|
-
}
|
|
111
|
-
function setUnitInDate(date, unit, value, utc) {
|
|
112
|
-
const field = unitToField(unit);
|
|
113
|
-
const method = `set${utc ? "UTC" : ""}${field}`;
|
|
114
|
-
date[method](...isArray(value) ? value : [value]);
|
|
115
|
-
return date;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// src/common/esday-inst.ts
|
|
119
|
-
function createInstanceFromExist(d, existInst) {
|
|
120
|
-
const newInst = existInst.clone();
|
|
121
|
-
newInst["$d"] = d;
|
|
122
|
-
return newInst;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// src/common/str-utils.ts
|
|
126
|
-
function padStart(origin, length, pad) {
|
|
127
|
-
const originStr = String(origin);
|
|
128
|
-
if (!originStr || originStr.length >= length)
|
|
129
|
-
return originStr;
|
|
130
|
-
return `${Array.from({ length: length + 1 - originStr.length }).join(pad)}${originStr}`;
|
|
131
|
-
}
|
|
132
|
-
function padZoneStr(utcOffset) {
|
|
133
|
-
const negMinutes = -utcOffset;
|
|
134
|
-
const minutes = Math.abs(negMinutes);
|
|
135
|
-
const hourOffset = Math.floor(minutes / 60);
|
|
136
|
-
const minuteOffset = minutes % 60;
|
|
137
|
-
return `${negMinutes <= 0 ? "+" : "-"}${padStart(hourOffset, 2, "0")}:${padStart(minuteOffset, 2, "0")}`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export { constant_exports, createInstanceFromExist, getUnitInDate, isEmptyObject, isObject, isString, isUndefined, padStart, padZoneStr, prettyUnit, setUnitInDate, undefinedOr };
|