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/plugins/isoWeek/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { constants_default } from "../../chunks/
|
|
2
|
-
import { isUndefined } from "../../chunks/
|
|
3
|
-
import { createInstanceFromExist } from "../../chunks/
|
|
4
|
-
import { padStart } from "../../chunks/
|
|
1
|
+
import { p as constants_default } from "../../chunks/BkjWOpMU.js";
|
|
2
|
+
import { a as isUndefined } from "../../chunks/v_QBn7Xm.js";
|
|
3
|
+
import { t as createInstanceFromExist } from "../../chunks/Shk32pTP.js";
|
|
4
|
+
import { n as padStart } from "../../chunks/CdvTtmWL.js";
|
|
5
5
|
|
|
6
6
|
//#region src/plugins/isoWeek/index.ts
|
|
7
7
|
const weekStart = constants_default.INDEX_MONDAY;
|
|
@@ -43,8 +43,7 @@ function addIsoWeekProperty(property) {
|
|
|
43
43
|
* @returns converted 4-digit year
|
|
44
44
|
*/
|
|
45
45
|
function parseTwoDigitYear(input) {
|
|
46
|
-
const
|
|
47
|
-
const year = +inputLimited;
|
|
46
|
+
const year = +input.slice(0, 2);
|
|
48
47
|
return year + (year > 68 ? 1900 : 2e3);
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
@@ -71,8 +70,7 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
71
70
|
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(parsedElements.isoWeek)) && isUndefined(parsedElements.date)) {
|
|
72
71
|
const newEsday = createInstanceFromExist(parsedDate, this);
|
|
73
72
|
const parsedIsoWeek = parsedElements.isoWeek;
|
|
74
|
-
|
|
75
|
-
modifiedDate = modifiedEsday.toDate();
|
|
73
|
+
modifiedDate = newEsday.isoWeek(parsedIsoWeek).isoWeekday(weekStart).toDate();
|
|
76
74
|
}
|
|
77
75
|
return modifiedDate;
|
|
78
76
|
}
|
|
@@ -89,8 +87,7 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
89
87
|
if (!(Number.isNaN(parsedDate.valueOf()) || isUndefined(parsedElements.isoWeekday)) && isUndefined(parsedElements.month)) {
|
|
90
88
|
const newEsday = createInstanceFromExist(parsedDate, this);
|
|
91
89
|
const newIsoWeekday = parsedElements.isoWeekday;
|
|
92
|
-
|
|
93
|
-
modifiedDate = modifiedEsday.toDate();
|
|
90
|
+
modifiedDate = newEsday.isoWeekday(newIsoWeekday).toDate();
|
|
94
91
|
}
|
|
95
92
|
return modifiedDate;
|
|
96
93
|
}
|
|
@@ -111,10 +108,7 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
111
108
|
let modifiedEsday = newEsday.isoWeekYear(parsedIsoWeekYear);
|
|
112
109
|
modifiedEsday = modifiedEsday.year(parsedIsoWeekYear).isoWeek(1).isoWeekday(1);
|
|
113
110
|
modifiedDate = modifiedEsday.toDate();
|
|
114
|
-
} else if (!isUndefined(parsedElements.isoWeek))
|
|
115
|
-
const modifiedEsday = newEsday.isoWeekYear(parsedIsoWeekYear);
|
|
116
|
-
modifiedDate = modifiedEsday.toDate();
|
|
117
|
-
}
|
|
111
|
+
} else if (!isUndefined(parsedElements.isoWeek)) modifiedDate = newEsday.isoWeekYear(parsedIsoWeekYear).toDate();
|
|
118
112
|
}
|
|
119
113
|
return modifiedDate;
|
|
120
114
|
}
|
|
@@ -131,8 +125,7 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
131
125
|
return this.add((newIsoWeek - this.isoWeek()) * 7, constants_default.DAY).isoWeekday(currentWeekday).hour(h, m, s, ms);
|
|
132
126
|
}
|
|
133
127
|
let yearStartDate = this.month(0, yearStart).hour(0, 0, 0, 0);
|
|
134
|
-
const
|
|
135
|
-
const diffToWeekStart = (7 + yearStartWeekday - weekStart) % 7;
|
|
128
|
+
const diffToWeekStart = (7 + yearStartDate.day() - weekStart) % 7;
|
|
136
129
|
yearStartDate = yearStartDate.subtract(diffToWeekStart, constants_default.DAY);
|
|
137
130
|
if (this.valueOf() < yearStartDate.valueOf()) return this.subtract(1, constants_default.YEAR).isoWeeksInYear();
|
|
138
131
|
return this.diff(yearStartDate, constants_default.WEEK) + 1;
|
|
@@ -185,21 +178,17 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
185
178
|
};
|
|
186
179
|
const oldEndOf = proto.endOf;
|
|
187
180
|
proto.endOf = function(units) {
|
|
188
|
-
if (units === constants_default.ISOWEEK)
|
|
189
|
-
const weekEnd = 7;
|
|
190
|
-
return this.date(this.date() + (weekEnd - this.isoWeekday())).endOf(constants_default.DAY);
|
|
191
|
-
}
|
|
181
|
+
if (units === constants_default.ISOWEEK) return this.date(this.date() + (7 - this.isoWeekday())).endOf(constants_default.DAY);
|
|
192
182
|
return oldEndOf.call(this, units);
|
|
193
183
|
};
|
|
194
|
-
|
|
184
|
+
dayFactory.addFormatTokenDefinitions({
|
|
195
185
|
W: (sourceDate) => sourceDate.isoWeek().toString(),
|
|
196
186
|
WW: (sourceDate) => padStart(sourceDate.isoWeek(), 2, "0"),
|
|
197
187
|
Wo: (sourceDate) => toOrdinal(sourceDate, sourceDate.isoWeek()),
|
|
198
188
|
E: (sourceDate) => sourceDate.isoWeekday().toString(),
|
|
199
189
|
GG: (sourceDate) => padStart(sourceDate.isoWeekYear(), 2, "0").slice(-2),
|
|
200
190
|
GGGG: (sourceDate) => padStart(sourceDate.isoWeekYear(), 4, "0")
|
|
201
|
-
};
|
|
202
|
-
dayFactory.addFormatTokenDefinitions(additionalTokens);
|
|
191
|
+
});
|
|
203
192
|
const parseTokensDefinitions = {
|
|
204
193
|
W: [
|
|
205
194
|
match1to2,
|
|
@@ -234,7 +223,6 @@ const isoWeekPlugin = (_, dayClass, dayFactory) => {
|
|
|
234
223
|
};
|
|
235
224
|
dayFactory.addParseTokenDefinitions?.(parseTokensDefinitions);
|
|
236
225
|
};
|
|
237
|
-
var isoWeek_default = isoWeekPlugin;
|
|
238
226
|
|
|
239
227
|
//#endregion
|
|
240
|
-
export {
|
|
228
|
+
export { isoWeekPlugin as default };
|
|
@@ -1,4 +1,104 @@
|
|
|
1
|
-
import "../../chunks/
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { o as EsDayPlugin, t as EsDay } from "../../chunks/CODi8AFH.js";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/locale/types.d.ts
|
|
4
|
+
type ReadonlyTuple<T, N extends number, R extends readonly T[] = []> = R['length'] extends N ? R : ReadonlyTuple<T, N, readonly [T, ...R]>;
|
|
5
|
+
declare module 'esday' {
|
|
6
|
+
interface EsDay {
|
|
7
|
+
locale(): string;
|
|
8
|
+
locale(localeName: string): EsDay;
|
|
9
|
+
localeObject: () => Locale;
|
|
10
|
+
}
|
|
11
|
+
interface EsDayFactory {
|
|
12
|
+
locale(): string;
|
|
13
|
+
locale(localeName: string): EsDay;
|
|
14
|
+
registerLocale: (locale: Locale, newName?: string) => EsDayFactory;
|
|
15
|
+
unregisterLocale: (localeName: string) => EsDayFactory;
|
|
16
|
+
getLocale: (localeName: string) => Locale;
|
|
17
|
+
updateLocale: (localeName: string, newLocale: Partial<Locale>) => EsDayFactory;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
type DayNames<T = string> = ReadonlyTuple<T, 7>;
|
|
21
|
+
interface DayNamesStandaloneFormat<T = DayNames<string>> {
|
|
22
|
+
format: T;
|
|
23
|
+
standalone: T;
|
|
24
|
+
isFormat: RegExp;
|
|
25
|
+
}
|
|
26
|
+
type MonthNames<T = string> = ReadonlyTuple<T, 12>;
|
|
27
|
+
interface MonthNamesStandaloneFormat<T = MonthNames<string>> {
|
|
28
|
+
format: T;
|
|
29
|
+
standalone: T;
|
|
30
|
+
isFormat?: RegExp;
|
|
31
|
+
}
|
|
32
|
+
interface MonthNamesFunction<T = MonthNames<string>> {
|
|
33
|
+
(esdayInstance: EsDay, format: string): string;
|
|
34
|
+
format: T;
|
|
35
|
+
standalone: T;
|
|
36
|
+
}
|
|
37
|
+
type LocaleFormatKeys = 'LT' | 'LTS' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'l' | 'll' | 'lll' | 'llll';
|
|
38
|
+
type CalendarSpecValFunction = (this: EsDay, refDate?: EsDay) => string;
|
|
39
|
+
type CalendarSpecVal = string | CalendarSpecValFunction;
|
|
40
|
+
interface Calendar {
|
|
41
|
+
sameDay: CalendarSpecVal;
|
|
42
|
+
nextDay: CalendarSpecVal;
|
|
43
|
+
nextWeek: CalendarSpecVal;
|
|
44
|
+
lastDay: CalendarSpecVal;
|
|
45
|
+
lastWeek: CalendarSpecVal;
|
|
46
|
+
sameElse: CalendarSpecVal;
|
|
47
|
+
}
|
|
48
|
+
type CalendarPartial = Partial<Calendar>;
|
|
49
|
+
type RelativeTimeKeys = 'future' | 'past' | 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'w' | 'ww' | 'M' | 'MM' | 'y' | 'yy';
|
|
50
|
+
type RelativeTimeElementFunction = (timeValue: string | number, withoutSuffix: boolean, token: RelativeTimeKeys, isFuture: boolean) => string;
|
|
51
|
+
interface Locale {
|
|
52
|
+
/**
|
|
53
|
+
* Name of the locale
|
|
54
|
+
*/
|
|
55
|
+
readonly name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Array of full day names
|
|
58
|
+
* @example ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
|
59
|
+
*/
|
|
60
|
+
readonly weekdays: DayNames | DayNamesStandaloneFormat;
|
|
61
|
+
/**
|
|
62
|
+
* Array of short versions of day names
|
|
63
|
+
* @example ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
64
|
+
*/
|
|
65
|
+
readonly weekdaysShort: DayNames;
|
|
66
|
+
/**
|
|
67
|
+
* Array of minimal versions of day names
|
|
68
|
+
* @example ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
|
|
69
|
+
*/
|
|
70
|
+
readonly weekdaysMin: DayNames;
|
|
71
|
+
readonly months: MonthNames | MonthNamesStandaloneFormat | MonthNamesFunction;
|
|
72
|
+
readonly monthsShort: MonthNames | MonthNamesStandaloneFormat | MonthNamesFunction;
|
|
73
|
+
readonly dayOfMonthOrdinalParse: RegExp;
|
|
74
|
+
readonly ordinal: (number: number, period?: string) => string;
|
|
75
|
+
readonly weekStart: number;
|
|
76
|
+
readonly yearStart: number;
|
|
77
|
+
readonly formats: Record<LocaleFormatKeys, string>;
|
|
78
|
+
readonly calendar: Calendar;
|
|
79
|
+
readonly relativeTime: Record<RelativeTimeKeys, string | RelativeTimeElementFunction>;
|
|
80
|
+
readonly meridiem: (hour: number, minute: number, isLowercase: boolean) => string;
|
|
81
|
+
readonly preParse?: (dateString: string) => string;
|
|
82
|
+
readonly postFormat?: (formattedDate: string) => string;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/plugins/locale/index.d.ts
|
|
86
|
+
/**
|
|
87
|
+
* Set a property in a literal object avoiding a typescript error TS2322.
|
|
88
|
+
* @param targetLocale - object whose property to create or set
|
|
89
|
+
* @param propName - name of the property to create or set
|
|
90
|
+
* @param newValue - new value of the property
|
|
91
|
+
*/
|
|
92
|
+
declare function setLocaleProperty(targetLocale: Locale, propName: string, newValue: any): void;
|
|
93
|
+
/**
|
|
94
|
+
* Clone a Locale. Used to create a locale for a territory based
|
|
95
|
+
* on the locale of the corresponding language.
|
|
96
|
+
* All properties of the cloned locale are 'readonly' and can only
|
|
97
|
+
* be set by using the function 'setProperty'.
|
|
98
|
+
* @param source - locale to clone
|
|
99
|
+
* @returns cloned locale with all all properties set to 'readonly'.
|
|
100
|
+
*/
|
|
101
|
+
declare function cloneLocale(source: Locale): Locale;
|
|
102
|
+
declare const localePlugin: EsDayPlugin<{}>;
|
|
103
|
+
//#endregion
|
|
4
104
|
export { Calendar, CalendarPartial, CalendarSpecVal, CalendarSpecValFunction, DayNames, DayNamesStandaloneFormat, Locale, LocaleFormatKeys, MonthNames, MonthNamesFunction, MonthNamesStandaloneFormat, RelativeTimeElementFunction, RelativeTimeKeys, cloneLocale, localePlugin as default, setLocaleProperty };
|
package/plugins/locale/index.js
CHANGED
|
@@ -1,7 +1,141 @@
|
|
|
1
|
-
import "../../chunks/
|
|
2
|
-
import "../../chunks/
|
|
3
|
-
import "../../chunks/
|
|
4
|
-
import "../../
|
|
5
|
-
import { cloneLocale, locale_default, setLocaleProperty } from "../../chunks/CoBtJ4c1.js";
|
|
1
|
+
import { p as constants_default } from "../../chunks/BkjWOpMU.js";
|
|
2
|
+
import { s as undefinedOr } from "../../chunks/v_QBn7Xm.js";
|
|
3
|
+
import { t as normalizeUnit } from "../../chunks/AyQQ6US-.js";
|
|
4
|
+
import localeEn from "../../locales/en.js";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
//#region src/plugins/locale/index.ts
|
|
7
|
+
const LocaleStore = /* @__PURE__ */ new Map();
|
|
8
|
+
let $localeGlobal = "en";
|
|
9
|
+
function getLocale(name) {
|
|
10
|
+
return LocaleStore.get(name) || localeEn;
|
|
11
|
+
}
|
|
12
|
+
function registerLocale(locale, rename) {
|
|
13
|
+
LocaleStore.set(rename || locale.name, locale);
|
|
14
|
+
}
|
|
15
|
+
function unregisterLocale(name) {
|
|
16
|
+
LocaleStore.delete(name);
|
|
17
|
+
}
|
|
18
|
+
function updateLocale(localeName, locale) {
|
|
19
|
+
const updatedLocale = {
|
|
20
|
+
...getLocale(localeName),
|
|
21
|
+
...locale
|
|
22
|
+
};
|
|
23
|
+
LocaleStore.set(localeName, updatedLocale);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Same as 'setLocaleProperty', but for arbitrary objects to enable use
|
|
27
|
+
* e.g. for cloning the 'relativeTime' property.
|
|
28
|
+
* @param target - object whose property to create or set
|
|
29
|
+
* @param propName - name of the property to create or set
|
|
30
|
+
* @param newValue - new value of the property
|
|
31
|
+
*/
|
|
32
|
+
function setObjectProperty(target, propName, newValue) {
|
|
33
|
+
Object.defineProperty(target, propName, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: false,
|
|
37
|
+
value: newValue
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set a property in a literal object avoiding a typescript error TS2322.
|
|
42
|
+
* @param targetLocale - object whose property to create or set
|
|
43
|
+
* @param propName - name of the property to create or set
|
|
44
|
+
* @param newValue - new value of the property
|
|
45
|
+
*/
|
|
46
|
+
function setLocaleProperty(targetLocale, propName, newValue) {
|
|
47
|
+
setObjectProperty(targetLocale, propName, newValue);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Clone an object. Used for cloning a Locale, but with a generic
|
|
51
|
+
* name, as we call it recursively.
|
|
52
|
+
* @param sourceObject - object to clone
|
|
53
|
+
* @returns cloned object with all properties set to 'readonly'.
|
|
54
|
+
*/
|
|
55
|
+
function cloneObject(sourceObject) {
|
|
56
|
+
const result = {};
|
|
57
|
+
for (const [key, sourceValue] of Object.entries(sourceObject)) if (typeof sourceValue === "string" || typeof sourceValue === "number" || typeof sourceValue === "function") setObjectProperty(result, key, sourceValue);
|
|
58
|
+
else if (Array.isArray(sourceValue)) setObjectProperty(result, key, structuredClone(sourceValue));
|
|
59
|
+
else if (sourceValue instanceof RegExp) setObjectProperty(result, key, new RegExp(sourceValue.source, sourceValue.flags));
|
|
60
|
+
else if (typeof sourceValue === "object") setObjectProperty(result, key, cloneObject(sourceValue));
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clone a Locale. Used to create a locale for a territory based
|
|
65
|
+
* on the locale of the corresponding language.
|
|
66
|
+
* All properties of the cloned locale are 'readonly' and can only
|
|
67
|
+
* be set by using the function 'setProperty'.
|
|
68
|
+
* @param source - locale to clone
|
|
69
|
+
* @returns cloned locale with all all properties set to 'readonly'.
|
|
70
|
+
*/
|
|
71
|
+
function cloneLocale(source) {
|
|
72
|
+
return cloneObject(source);
|
|
73
|
+
}
|
|
74
|
+
function getSetPrivateLocaleName(inst, newLocaleName) {
|
|
75
|
+
if (newLocaleName) inst["$conf"]["localeName"] = newLocaleName;
|
|
76
|
+
return inst["$conf"]["localeName"] || "";
|
|
77
|
+
}
|
|
78
|
+
const localePlugin = (_, dayClass, dayFactory) => {
|
|
79
|
+
dayClass.prototype.localeObject = function() {
|
|
80
|
+
return getLocale(getSetPrivateLocaleName(this));
|
|
81
|
+
};
|
|
82
|
+
dayClass.prototype.locale = function(localeName) {
|
|
83
|
+
if (localeName === void 0) return getSetPrivateLocaleName(this);
|
|
84
|
+
const inst = this.clone();
|
|
85
|
+
getSetPrivateLocaleName(inst, localeName);
|
|
86
|
+
return inst;
|
|
87
|
+
};
|
|
88
|
+
const oldClone = dayClass.prototype["clone"];
|
|
89
|
+
dayClass.prototype["clone"] = function() {
|
|
90
|
+
const inst = oldClone.call(this);
|
|
91
|
+
getSetPrivateLocaleName(inst, getSetPrivateLocaleName(this));
|
|
92
|
+
return inst;
|
|
93
|
+
};
|
|
94
|
+
const oldParse = dayClass.prototype["$parse"];
|
|
95
|
+
dayClass.prototype["$parse"] = function(d) {
|
|
96
|
+
getSetPrivateLocaleName(this, $localeGlobal);
|
|
97
|
+
oldParse.call(this, d);
|
|
98
|
+
};
|
|
99
|
+
const oldStartOf = dayClass.prototype["startOf"];
|
|
100
|
+
const oldEndOf = dayClass.prototype["endOf"];
|
|
101
|
+
const fixDiff = (inst, origin, unit, reverse = false) => {
|
|
102
|
+
if (normalizeUnit(unit) === constants_default.WEEK) {
|
|
103
|
+
const defaultStartOfWeek = constants_default.INDEX_MONDAY;
|
|
104
|
+
const weekStart = undefinedOr(inst.localeObject().weekStart, defaultStartOfWeek);
|
|
105
|
+
const $day = origin.day();
|
|
106
|
+
const $date = origin.date();
|
|
107
|
+
const diff = ($day < weekStart ? $day + 7 : $day) - weekStart;
|
|
108
|
+
return origin.date(reverse ? $date + (6 - diff) : $date - diff).hour(inst.hour(), inst.minute(), inst.second(), inst.millisecond());
|
|
109
|
+
}
|
|
110
|
+
return inst;
|
|
111
|
+
};
|
|
112
|
+
dayClass.prototype["startOf"] = function(unit) {
|
|
113
|
+
return fixDiff(oldStartOf.call(this, unit), this, unit);
|
|
114
|
+
};
|
|
115
|
+
dayClass.prototype["endOf"] = function(unit) {
|
|
116
|
+
return fixDiff(oldEndOf.call(this, unit), this, unit, true);
|
|
117
|
+
};
|
|
118
|
+
dayFactory.locale = (localeName) => {
|
|
119
|
+
if (localeName === void 0) return $localeGlobal;
|
|
120
|
+
$localeGlobal = localeName;
|
|
121
|
+
return dayFactory;
|
|
122
|
+
};
|
|
123
|
+
dayFactory.registerLocale = (locale, newName) => {
|
|
124
|
+
registerLocale(locale, newName);
|
|
125
|
+
return dayFactory;
|
|
126
|
+
};
|
|
127
|
+
dayFactory.unregisterLocale = (localeName) => {
|
|
128
|
+
unregisterLocale(localeName);
|
|
129
|
+
return dayFactory;
|
|
130
|
+
};
|
|
131
|
+
dayFactory.getLocale = (localeName) => {
|
|
132
|
+
return getLocale(localeName);
|
|
133
|
+
};
|
|
134
|
+
dayFactory.updateLocale = (localeName, locale) => {
|
|
135
|
+
updateLocale(localeName, locale);
|
|
136
|
+
return dayFactory;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { cloneLocale, localePlugin as default, setLocaleProperty };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { EsDayPlugin } from "../../chunks/
|
|
2
|
-
import "../../chunks/MtjcOKi-.js";
|
|
1
|
+
import { o as EsDayPlugin } from "../../chunks/CODi8AFH.js";
|
|
3
2
|
|
|
4
3
|
//#region src/plugins/localeData/index.d.ts
|
|
5
|
-
|
|
6
4
|
declare const localeDataPlugin: EsDayPlugin<{}>;
|
|
7
5
|
//#endregion
|
|
8
6
|
export { localeDataPlugin as default };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { t as esday } from "../../chunks/CXWzCl3n.js";
|
|
2
|
+
|
|
1
3
|
//#region src/plugins/localeData/index.ts
|
|
2
4
|
/**
|
|
5
|
+
* LocaleData plugin
|
|
6
|
+
*
|
|
7
|
+
* This plugin adds 'method1', 'method2' and formatting and parsing tokens to EsDay
|
|
8
|
+
*
|
|
9
|
+
* This plugin requires the 'Locale' plugin. For using the 'weekdays' function to
|
|
10
|
+
* format a date, the plugin 'Week' is required too.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
3
13
|
* Get list of month names or format a date as month (short or long month name).
|
|
4
14
|
* @param locale - locale to use
|
|
5
15
|
* @param propName - name of the property to extract
|
|
@@ -69,8 +79,7 @@ const getMonths = (locale, propName, date, format) => {
|
|
|
69
79
|
* @returns full format of abbreviated date-time format
|
|
70
80
|
*/
|
|
71
81
|
const getLongDateFormat = (locale, format) => {
|
|
72
|
-
|
|
73
|
-
return formatsArray[format] ?? "";
|
|
82
|
+
return locale.formats[format] ?? "";
|
|
74
83
|
};
|
|
75
84
|
/**
|
|
76
85
|
* Get a locale dependant format for relative dates.
|
|
@@ -85,8 +94,10 @@ const getCalendar = (locale, key, date, now) => {
|
|
|
85
94
|
const defaultKey = "sameElse";
|
|
86
95
|
const calendarArray = locale.calendar;
|
|
87
96
|
const calendarEntry = calendarArray[key ?? defaultKey] ?? calendarArray[defaultKey];
|
|
97
|
+
const nowDate = now ?? esday();
|
|
88
98
|
if (typeof calendarEntry === "function") {
|
|
89
|
-
|
|
99
|
+
/* istanbul ignore else -- @preserve */
|
|
100
|
+
if (date !== void 0) result = calendarEntry.call(date, nowDate);
|
|
90
101
|
} else result = calendarEntry;
|
|
91
102
|
return result;
|
|
92
103
|
};
|
|
@@ -101,8 +112,7 @@ const getCalendar = (locale, key, date, now) => {
|
|
|
101
112
|
*/
|
|
102
113
|
const getRelativeTime = (locale, timeValue, withoutSuffix, token, isFuture) => {
|
|
103
114
|
let result = "";
|
|
104
|
-
const
|
|
105
|
-
const relativeTimeEntry = relativeTimeArray[token];
|
|
115
|
+
const relativeTimeEntry = locale.relativeTime[token];
|
|
106
116
|
if (typeof relativeTimeEntry === "function") result = relativeTimeEntry(timeValue, withoutSuffix, token, isFuture);
|
|
107
117
|
else result = relativeTimeEntry.replace(/%d/i, timeValue.toString());
|
|
108
118
|
return result;
|
|
@@ -129,12 +139,10 @@ const createLocaleDataObject = (locale) => {
|
|
|
129
139
|
const localeDataPlugin = (_, dayClass, dayFactory) => {
|
|
130
140
|
const proto = dayClass.prototype;
|
|
131
141
|
proto.localeData = function() {
|
|
132
|
-
|
|
133
|
-
return createLocaleDataObject(locale);
|
|
142
|
+
return createLocaleDataObject(this.localeObject());
|
|
134
143
|
};
|
|
135
144
|
dayFactory.localeData = (localeName) => {
|
|
136
|
-
|
|
137
|
-
return createLocaleDataObject(locale);
|
|
145
|
+
return createLocaleDataObject(localeName !== void 0 ? dayFactory.getLocale(localeName) : dayFactory.getLocale(dayFactory.locale()));
|
|
138
146
|
};
|
|
139
147
|
dayFactory.months = () => getMonths(dayFactory.getLocale(dayFactory.locale()), "months");
|
|
140
148
|
dayFactory.monthsShort = () => getMonths(dayFactory.getLocale(dayFactory.locale()), "monthsShort");
|
|
@@ -142,7 +150,6 @@ const localeDataPlugin = (_, dayClass, dayFactory) => {
|
|
|
142
150
|
dayFactory.weekdaysShort = () => getWeekdays(dayFactory.getLocale(dayFactory.locale()), "weekdaysShort");
|
|
143
151
|
dayFactory.weekdaysMin = () => getWeekdays(dayFactory.getLocale(dayFactory.locale()), "weekdaysMin");
|
|
144
152
|
};
|
|
145
|
-
var localeData_default = localeDataPlugin;
|
|
146
153
|
|
|
147
154
|
//#endregion
|
|
148
|
-
export {
|
|
155
|
+
export { localeDataPlugin as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { EsDayPlugin } from "../../chunks/
|
|
2
|
-
import "../../chunks/MtjcOKi-.js";
|
|
1
|
+
import { o as EsDayPlugin } from "../../chunks/CODi8AFH.js";
|
|
3
2
|
|
|
4
3
|
//#region src/plugins/localizedFormat/index.d.ts
|
|
5
|
-
|
|
6
4
|
declare const localizedFormatPlugin: EsDayPlugin<{}>;
|
|
7
5
|
//#endregion
|
|
8
6
|
export { localizedFormatPlugin as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { padNumberWithLeadingZeros } from "../../chunks/
|
|
1
|
+
import { i as isString, t as isArray } from "../../chunks/v_QBn7Xm.js";
|
|
2
|
+
import { t as padNumberWithLeadingZeros } from "../../chunks/CdvTtmWL.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/localizedFormat/index.ts
|
|
5
5
|
/**
|
|
@@ -11,9 +11,7 @@ function addWeekday() {
|
|
|
11
11
|
return function weekdayFormatter(sourceDate, format) {
|
|
12
12
|
const weekdays = sourceDate.localeObject().weekdays;
|
|
13
13
|
if (isArray(weekdays)) return weekdays[sourceDate.day()];
|
|
14
|
-
|
|
15
|
-
const useFormatProperty = parseForUseFormat?.test(format);
|
|
16
|
-
if (useFormatProperty) return weekdays.format[sourceDate.day()];
|
|
14
|
+
if (weekdays.isFormat?.test(format)) return weekdays.format[sourceDate.day()];
|
|
17
15
|
return weekdays.standalone[sourceDate.day()];
|
|
18
16
|
};
|
|
19
17
|
}
|
|
@@ -29,9 +27,7 @@ function addMonth(property) {
|
|
|
29
27
|
const months = sourceDate.localeObject()[property];
|
|
30
28
|
if (isArray(months)) return months[sourceDate.month()];
|
|
31
29
|
if (typeof months === "function") return months(sourceDate, format);
|
|
32
|
-
|
|
33
|
-
const useFormatProperty = parseForUseFormat.test(format);
|
|
34
|
-
if (useFormatProperty) return months.format[sourceDate.month()];
|
|
30
|
+
if ((months.isFormat ?? MONTHS_IN_FORMAT).test(format)) return months.format[sourceDate.month()];
|
|
35
31
|
return months.standalone[sourceDate.month()];
|
|
36
32
|
};
|
|
37
33
|
}
|
|
@@ -82,7 +78,6 @@ const localizedFormatPlugin = (_, dayClass, dayFactory) => {
|
|
|
82
78
|
return this.localeObject?.().postFormat?.(formattedValue) ?? formattedValue;
|
|
83
79
|
};
|
|
84
80
|
};
|
|
85
|
-
var localizedFormat_default = localizedFormatPlugin;
|
|
86
81
|
|
|
87
82
|
//#endregion
|
|
88
|
-
export {
|
|
83
|
+
export { localizedFormatPlugin as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { EsDayPlugin } from "../../chunks/
|
|
2
|
-
import "../../chunks/MtjcOKi-.js";
|
|
1
|
+
import { o as EsDayPlugin } from "../../chunks/CODi8AFH.js";
|
|
3
2
|
|
|
4
3
|
//#region src/plugins/localizedParse/index.d.ts
|
|
5
|
-
|
|
6
4
|
declare const localizedParsePlugin: EsDayPlugin<{}>;
|
|
7
5
|
//#endregion
|
|
8
6
|
export { localizedParsePlugin as default };
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as isUndefined, i as isString, t as isArray } from "../../chunks/v_QBn7Xm.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugins/localizedParse/index.ts
|
|
4
4
|
const match2 = /\d{2}/;
|
|
5
5
|
const match1to2 = /\d\d?/;
|
|
6
6
|
const matchWord = /\d*[^-_:/,()\s\d]+/;
|
|
7
|
+
const matchDayOfMonthOrdinalDefault = /\d{1,2}/;
|
|
8
|
+
/**
|
|
9
|
+
* Update parsing patterns that depend on the locale (e.g. 'Do')
|
|
10
|
+
* @param patterns - parseTokensDefinitions
|
|
11
|
+
* @param locale - locale to use
|
|
12
|
+
*/
|
|
13
|
+
const updateParsingPatternsFromLocale = (patterns, locale) => {
|
|
14
|
+
const dayOfMonthOrdinalPattern = locale.dayOfMonthOrdinalParse;
|
|
15
|
+
patterns.Do[0] = dayOfMonthOrdinalPattern;
|
|
16
|
+
patterns.Do[1] = dayOfMonthOrdinalPattern;
|
|
17
|
+
};
|
|
7
18
|
/**
|
|
8
19
|
* Add 'input' to parsedElements as 'hours'.
|
|
9
20
|
* @param parsedElements - object containing the components of a parsed date
|
|
10
21
|
* @param input - parsed component of a date, to be transformed and inserted in parsedElements
|
|
11
22
|
* @param options - parsing options e.g. containing the locale to use
|
|
12
23
|
*/
|
|
13
|
-
|
|
24
|
+
const addHour = (parsedElements, input, _parseOptions) => {
|
|
14
25
|
parsedElements["hours"] = +input;
|
|
15
|
-
}
|
|
26
|
+
};
|
|
16
27
|
/**
|
|
17
28
|
* Convert parsed string to boolean 'afternoon'
|
|
18
29
|
* @param locale - Locale to use
|
|
@@ -20,7 +31,7 @@ function addHour(parsedElements, input, _parseOptions) {
|
|
|
20
31
|
* @param isLowerCase - should this be a lowercase meridiem string?
|
|
21
32
|
* @returns is input an 'afternoon' string for given locale
|
|
22
33
|
*/
|
|
23
|
-
|
|
34
|
+
const meridiemMatch = (locale, input, isLowerCase) => {
|
|
24
35
|
let isAfternoon = false;
|
|
25
36
|
const { meridiem } = locale;
|
|
26
37
|
if (meridiem) {
|
|
@@ -30,7 +41,7 @@ function meridiemMatch(locale, input, isLowerCase) {
|
|
|
30
41
|
}
|
|
31
42
|
} else isAfternoon = input === (isLowerCase ? "pm" : "PM");
|
|
32
43
|
return isAfternoon;
|
|
33
|
-
}
|
|
44
|
+
};
|
|
34
45
|
/**
|
|
35
46
|
* Create a function that will parse the input string as meridiem string and
|
|
36
47
|
* add it to the given 'parsedElements' containing the date&time components.
|
|
@@ -38,14 +49,12 @@ function meridiemMatch(locale, input, isLowerCase) {
|
|
|
38
49
|
* @param esday - global esday object (to get locale by its name)
|
|
39
50
|
* @returns function that will add the given value to date&time component as 'afternoon'
|
|
40
51
|
*/
|
|
41
|
-
|
|
52
|
+
const addAfternoon = (isLowerCase, esday) => {
|
|
42
53
|
return function meridiemUpdater(parsedElements, input, parseOptions) {
|
|
43
54
|
const localeName = parseOptions["locale"];
|
|
44
|
-
|
|
45
|
-
const meridiem = meridiemMatch(locale, input, isLowerCase);
|
|
46
|
-
if (!isUndefined(meridiem)) parsedElements.afternoon = meridiem;
|
|
55
|
+
parsedElements.afternoon = meridiemMatch(esday.getLocale(localeName), input, isLowerCase);
|
|
47
56
|
};
|
|
48
|
-
}
|
|
57
|
+
};
|
|
49
58
|
/**
|
|
50
59
|
* Parse day of month as ordinal number.
|
|
51
60
|
* Create a function that will parse the input string as day of month as ordinal
|
|
@@ -53,7 +62,7 @@ function addAfternoon(isLowerCase, esday) {
|
|
|
53
62
|
* @param esday - global esday object (to get locale by its name)
|
|
54
63
|
* @returns function that will add the given value to date&time component as 'afternoon'
|
|
55
64
|
*/
|
|
56
|
-
|
|
65
|
+
const addDayOfMonthOrdinal = (esday) => {
|
|
57
66
|
return function monthOrdinalUpdater(parsedElements, input, parseOptions) {
|
|
58
67
|
const localeName = parseOptions["locale"];
|
|
59
68
|
const { ordinal } = esday.getLocale(localeName);
|
|
@@ -61,11 +70,11 @@ function addDayOfMonthOrdinal(esday) {
|
|
|
61
70
|
const splittedInput = input.match(/^[^\d]*(\d+)[^\d]*$/);
|
|
62
71
|
if (splittedInput !== null) {
|
|
63
72
|
dateValue = +splittedInput[1];
|
|
64
|
-
const dateAsOrdinal = ordinal?.(dateValue);
|
|
73
|
+
const dateAsOrdinal = ordinal?.(dateValue, "d");
|
|
65
74
|
if (dateAsOrdinal === void 0 || dateAsOrdinal === input) parsedElements.date = dateValue;
|
|
66
75
|
}
|
|
67
76
|
};
|
|
68
|
-
}
|
|
77
|
+
};
|
|
69
78
|
/**
|
|
70
79
|
* Create a function that will convert the value from the input string
|
|
71
80
|
* to a month number and add it to the given 'parsedElements' containing
|
|
@@ -74,7 +83,7 @@ function addDayOfMonthOrdinal(esday) {
|
|
|
74
83
|
* @param esday - global esday object (to get locale by its name)
|
|
75
84
|
* @returns function that will add the given value to date&time component
|
|
76
85
|
*/
|
|
77
|
-
|
|
86
|
+
const addMonth = (property, esday) => {
|
|
78
87
|
return function monthUpdater(parsedElements, input, parseOptions) {
|
|
79
88
|
const localeName = parseOptions["locale"];
|
|
80
89
|
const months = esday.getLocale(localeName)[property];
|
|
@@ -84,7 +93,7 @@ function addMonth(property, esday) {
|
|
|
84
93
|
const matchIndex = monthNames.indexOf(input) + 1;
|
|
85
94
|
parsedElements.month = matchIndex % 12 || matchIndex;
|
|
86
95
|
};
|
|
87
|
-
}
|
|
96
|
+
};
|
|
88
97
|
/**
|
|
89
98
|
* Replace locale dependent token in given format with values from locale definition
|
|
90
99
|
* e.g. 'LTS' with 'h:mm:ss A'
|
|
@@ -92,13 +101,13 @@ function addMonth(property, esday) {
|
|
|
92
101
|
* @param currentLocale - Locale to use
|
|
93
102
|
* @returns format with locale dependent tokens replaced
|
|
94
103
|
*/
|
|
95
|
-
|
|
104
|
+
const replaceLocaleTokens = (format, currentLocale) => {
|
|
96
105
|
const localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
|
97
106
|
function replaceLongDateFormatTokens(input) {
|
|
98
107
|
return currentLocale.formats[input] ?? input;
|
|
99
108
|
}
|
|
100
109
|
return format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
|
101
|
-
}
|
|
110
|
+
};
|
|
102
111
|
const localizedParsePlugin = (_, dayClass, dayFactory) => {
|
|
103
112
|
const proto = dayClass.prototype;
|
|
104
113
|
/**
|
|
@@ -155,8 +164,8 @@ const localizedParsePlugin = (_, dayClass, dayFactory) => {
|
|
|
155
164
|
_postParseMeridiem
|
|
156
165
|
],
|
|
157
166
|
Do: [
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
matchDayOfMonthOrdinalDefault,
|
|
168
|
+
matchDayOfMonthOrdinalDefault,
|
|
160
169
|
addDayOfMonthOrdinal(dayFactory)
|
|
161
170
|
],
|
|
162
171
|
MMM: [
|
|
@@ -180,7 +189,11 @@ const localizedParsePlugin = (_, dayClass, dayFactory) => {
|
|
|
180
189
|
const format = this["$conf"].args_1;
|
|
181
190
|
let currentLocale = this.localeObject?.();
|
|
182
191
|
const arg2 = this["$conf"].args_2;
|
|
183
|
-
if (!isUndefined(arg2) && typeof arg2 === "string")
|
|
192
|
+
if (!isUndefined(arg2) && typeof arg2 === "string") {
|
|
193
|
+
currentLocale = dayFactory.getLocale(arg2);
|
|
194
|
+
this["$conf"].localeName = arg2;
|
|
195
|
+
}
|
|
196
|
+
updateParsingPatternsFromLocale(parseTokensDefinitions, currentLocale);
|
|
184
197
|
const parseOptions = this["$conf"].parseOptions ?? {};
|
|
185
198
|
parseOptions.locale = currentLocale.name;
|
|
186
199
|
this["$conf"].parseOptions = parseOptions;
|
|
@@ -191,9 +204,14 @@ const localizedParsePlugin = (_, dayClass, dayFactory) => {
|
|
|
191
204
|
let newDate = d;
|
|
192
205
|
if (currentLocale.preParse !== void 0) newDate = currentLocale.preParse(d);
|
|
193
206
|
oldParse.call(this, newDate);
|
|
207
|
+
if (this["$conf"].parseOptions !== void 0) {
|
|
208
|
+
/* istanbul ignore else -- @preserve */
|
|
209
|
+
if (this["$conf"].parseOptions?.locale !== void 0) delete this["$conf"].parseOptions.locale;
|
|
210
|
+
/* istanbul ignore else -- @preserve */
|
|
211
|
+
if (Object.keys(this["$conf"].parseOptions).length === 0) delete this["$conf"].parseOptions;
|
|
212
|
+
}
|
|
194
213
|
};
|
|
195
214
|
};
|
|
196
|
-
var localizedParse_default = localizedParsePlugin;
|
|
197
215
|
|
|
198
216
|
//#endregion
|
|
199
|
-
export {
|
|
217
|
+
export { localizedParsePlugin as default };
|