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.
Files changed (382) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +21 -21
  3. package/README.md +63 -51
  4. package/chunks/AyQQ6US-.js +84 -0
  5. package/chunks/{Y32qdU_5.js → BkjWOpMU.js} +7 -1
  6. package/chunks/{MtjcOKi-.d.ts → C5qDMHT5.d.ts} +2 -2
  7. package/chunks/{DqhiVwLi.d.ts → CODi8AFH.d.ts} +63 -35
  8. package/chunks/CXWzCl3n.js +481 -0
  9. package/chunks/{BRRrAbUl.js → CdvTtmWL.js} +2 -2
  10. package/chunks/{DXHbH1CI.js → Shk32pTP.js} +1 -1
  11. package/chunks/{Cb5SvF6r.js → v_QBn7Xm.js} +1 -1
  12. package/chunks/xt8C2lbv.js +38 -0
  13. package/index.d.ts +3 -3
  14. package/index.js +1 -571
  15. package/locales/af.d.ts +1 -3
  16. package/locales/af.js +4 -2
  17. package/locales/am.d.ts +1 -3
  18. package/locales/am.js +4 -2
  19. package/locales/ar-dz.d.ts +1 -3
  20. package/locales/ar-dz.js +7 -9
  21. package/locales/ar-iq.d.ts +1 -3
  22. package/locales/ar-iq.js +7 -9
  23. package/locales/ar-kw.d.ts +1 -3
  24. package/locales/ar-kw.js +7 -9
  25. package/locales/ar-ly.d.ts +1 -3
  26. package/locales/ar-ly.js +7 -9
  27. package/locales/ar-ma.d.ts +1 -3
  28. package/locales/ar-ma.js +7 -9
  29. package/locales/ar-sa.d.ts +1 -3
  30. package/locales/ar-sa.js +7 -9
  31. package/locales/ar-tn.d.ts +1 -3
  32. package/locales/ar-tn.js +7 -9
  33. package/locales/ar.d.ts +1 -3
  34. package/locales/ar.js +197 -2
  35. package/locales/az.d.ts +1 -3
  36. package/locales/az.js +4 -2
  37. package/locales/be.d.ts +1 -3
  38. package/locales/be.js +55 -59
  39. package/locales/bg.d.ts +1 -3
  40. package/locales/bg.js +4 -2
  41. package/locales/bi.d.ts +1 -3
  42. package/locales/bi.js +4 -2
  43. package/locales/bm.d.ts +1 -3
  44. package/locales/bm.js +4 -2
  45. package/locales/bn-bd.d.ts +1 -3
  46. package/locales/bn-bd.js +7 -9
  47. package/locales/bn.d.ts +1 -3
  48. package/locales/bn.js +136 -2
  49. package/locales/bo.d.ts +1 -3
  50. package/locales/bo.js +4 -2
  51. package/locales/br.d.ts +1 -3
  52. package/locales/br.js +10 -9
  53. package/locales/bs.d.ts +1 -3
  54. package/locales/bs.js +4 -2
  55. package/locales/ca.d.ts +1 -3
  56. package/locales/ca.js +35 -36
  57. package/locales/cs.d.ts +1 -3
  58. package/locales/cs.js +38 -34
  59. package/locales/cv.d.ts +1 -3
  60. package/locales/cv.js +4 -2
  61. package/locales/cy.d.ts +1 -3
  62. package/locales/cy.js +4 -2
  63. package/locales/da.d.ts +1 -3
  64. package/locales/da.js +4 -2
  65. package/locales/de-at.d.ts +1 -3
  66. package/locales/de-at.js +7 -9
  67. package/locales/de-ch.d.ts +1 -3
  68. package/locales/de-ch.js +7 -9
  69. package/locales/de.d.ts +1 -3
  70. package/locales/de.js +130 -2
  71. package/locales/dv.d.ts +1 -3
  72. package/locales/dv.js +4 -2
  73. package/locales/el.d.ts +1 -3
  74. package/locales/el.js +4 -2
  75. package/locales/en-au.d.ts +1 -3
  76. package/locales/en-au.js +7 -8
  77. package/locales/en-ca.d.ts +1 -3
  78. package/locales/en-ca.js +7 -8
  79. package/locales/en-gb.d.ts +1 -3
  80. package/locales/en-gb.js +9 -8
  81. package/locales/en-ie.d.ts +1 -3
  82. package/locales/en-ie.js +7 -8
  83. package/locales/en-il.d.ts +1 -3
  84. package/locales/en-il.js +7 -8
  85. package/locales/en-in.d.ts +1 -3
  86. package/locales/en-in.js +7 -8
  87. package/locales/en-nz.d.ts +1 -3
  88. package/locales/en-nz.js +7 -8
  89. package/locales/en-sg.d.ts +1 -3
  90. package/locales/en-sg.js +7 -8
  91. package/locales/en-tt.d.ts +1 -3
  92. package/locales/en-tt.js +7 -8
  93. package/locales/en-us.d.ts +1 -3
  94. package/locales/en-us.js +7 -8
  95. package/locales/en.d.ts +1 -3
  96. package/locales/en.js +116 -2
  97. package/locales/eo.d.ts +1 -3
  98. package/locales/eo.js +4 -2
  99. package/locales/es-do.d.ts +1 -3
  100. package/locales/es-do.js +7 -9
  101. package/locales/es-mx.d.ts +1 -3
  102. package/locales/es-mx.js +7 -9
  103. package/locales/es-pr.d.ts +1 -3
  104. package/locales/es-pr.js +7 -9
  105. package/locales/es-us.d.ts +1 -3
  106. package/locales/es-us.js +7 -9
  107. package/locales/es.d.ts +1 -3
  108. package/locales/es.js +117 -2
  109. package/locales/et.d.ts +1 -3
  110. package/locales/et.js +6 -2
  111. package/locales/eu.d.ts +1 -3
  112. package/locales/eu.js +4 -2
  113. package/locales/fa.d.ts +1 -3
  114. package/locales/fa.js +4 -2
  115. package/locales/fi.d.ts +1 -3
  116. package/locales/fi.js +8 -2
  117. package/locales/fil.d.ts +1 -3
  118. package/locales/fil.js +4 -2
  119. package/locales/fo.d.ts +1 -3
  120. package/locales/fo.js +4 -2
  121. package/locales/fr-ca.d.ts +1 -3
  122. package/locales/fr-ca.js +7 -9
  123. package/locales/fr-ch.d.ts +1 -3
  124. package/locales/fr-ch.js +7 -9
  125. package/locales/fr.d.ts +1 -3
  126. package/locales/fr.js +109 -2
  127. package/locales/fy.d.ts +1 -3
  128. package/locales/fy.js +4 -2
  129. package/locales/ga.d.ts +1 -3
  130. package/locales/ga.js +4 -2
  131. package/locales/gd.d.ts +1 -3
  132. package/locales/gd.js +4 -2
  133. package/locales/gl.d.ts +1 -3
  134. package/locales/gl.js +4 -2
  135. package/locales/gom-deva.d.ts +1 -3
  136. package/locales/gom-deva.js +34 -32
  137. package/locales/gom-latn.d.ts +1 -3
  138. package/locales/gom-latn.js +34 -32
  139. package/locales/gu.d.ts +1 -3
  140. package/locales/gu.js +4 -2
  141. package/locales/he.d.ts +1 -3
  142. package/locales/he.js +8 -5
  143. package/locales/hi.d.ts +1 -3
  144. package/locales/hi.js +34 -35
  145. package/locales/hr.d.ts +1 -3
  146. package/locales/hr.js +10 -4
  147. package/locales/ht.d.ts +1 -3
  148. package/locales/ht.js +4 -2
  149. package/locales/hu.d.ts +1 -3
  150. package/locales/hu.js +6 -2
  151. package/locales/hy-am.d.ts +1 -3
  152. package/locales/hy-am.js +34 -35
  153. package/locales/id.d.ts +1 -3
  154. package/locales/id.js +4 -2
  155. package/locales/is.d.ts +1 -3
  156. package/locales/is.js +14 -2
  157. package/locales/it-ch.d.ts +1 -3
  158. package/locales/it-ch.js +4 -9
  159. package/locales/it.d.ts +1 -3
  160. package/locales/it.js +120 -2
  161. package/locales/ja.d.ts +1 -4
  162. package/locales/ja.js +4 -2
  163. package/locales/jv.d.ts +1 -3
  164. package/locales/jv.js +4 -2
  165. package/locales/ka.d.ts +1 -3
  166. package/locales/ka.js +25 -26
  167. package/locales/kk.d.ts +1 -3
  168. package/locales/kk.js +4 -2
  169. package/locales/km.d.ts +1 -3
  170. package/locales/km.js +4 -2
  171. package/locales/kn.d.ts +1 -3
  172. package/locales/kn.js +4 -2
  173. package/locales/ko.d.ts +1 -3
  174. package/locales/ko.js +5 -3
  175. package/locales/ku.d.ts +1 -3
  176. package/locales/ku.js +4 -2
  177. package/locales/ky.d.ts +1 -3
  178. package/locales/ky.js +4 -2
  179. package/locales/lb.d.ts +1 -3
  180. package/locales/lb.js +5 -2
  181. package/locales/lo.d.ts +1 -3
  182. package/locales/lo.js +4 -2
  183. package/locales/lt.d.ts +1 -3
  184. package/locales/lt.js +4 -2
  185. package/locales/lv.d.ts +1 -3
  186. package/locales/lv.js +4 -2
  187. package/locales/me.d.ts +1 -3
  188. package/locales/me.js +33 -33
  189. package/locales/mi.d.ts +1 -3
  190. package/locales/mi.js +4 -2
  191. package/locales/mk.d.ts +1 -3
  192. package/locales/mk.js +4 -2
  193. package/locales/ml.d.ts +1 -3
  194. package/locales/ml.js +4 -2
  195. package/locales/mn.d.ts +1 -3
  196. package/locales/mn.js +37 -16
  197. package/locales/mr.d.ts +1 -3
  198. package/locales/mr.js +16 -2
  199. package/locales/ms-my.d.ts +1 -3
  200. package/locales/ms-my.js +7 -9
  201. package/locales/ms.d.ts +1 -3
  202. package/locales/ms.js +107 -2
  203. package/locales/mt.d.ts +1 -3
  204. package/locales/mt.js +4 -2
  205. package/locales/my.d.ts +1 -3
  206. package/locales/my.js +4 -2
  207. package/locales/nb.d.ts +1 -3
  208. package/locales/nb.js +4 -2
  209. package/locales/ne.d.ts +1 -3
  210. package/locales/ne.js +4 -2
  211. package/locales/nl-be.d.ts +1 -3
  212. package/locales/nl-be.js +7 -9
  213. package/locales/nl.d.ts +1 -3
  214. package/locales/nl.js +107 -2
  215. package/locales/nn.d.ts +1 -3
  216. package/locales/nn.js +4 -2
  217. package/locales/oc-lnc.d.ts +1 -3
  218. package/locales/oc-lnc.js +35 -36
  219. package/locales/pa-in.d.ts +1 -3
  220. package/locales/pa-in.js +4 -2
  221. package/locales/pl.d.ts +1 -3
  222. package/locales/pl.js +5 -2
  223. package/locales/pt-br.d.ts +1 -3
  224. package/locales/pt-br.js +7 -9
  225. package/locales/pt.d.ts +1 -3
  226. package/locales/pt.js +109 -2
  227. package/locales/rn.d.ts +1 -3
  228. package/locales/rn.js +4 -2
  229. package/locales/ro.d.ts +1 -3
  230. package/locales/ro.js +4 -2
  231. package/locales/ru.d.ts +1 -4
  232. package/locales/ru.js +83 -82
  233. package/locales/rw.d.ts +1 -3
  234. package/locales/rw.js +4 -2
  235. package/locales/sd.d.ts +1 -3
  236. package/locales/sd.js +4 -2
  237. package/locales/se.d.ts +1 -3
  238. package/locales/se.js +4 -2
  239. package/locales/si.d.ts +1 -3
  240. package/locales/si.js +4 -2
  241. package/locales/sk.d.ts +1 -3
  242. package/locales/sk.js +8 -2
  243. package/locales/sl.d.ts +1 -3
  244. package/locales/sl.js +8 -2
  245. package/locales/sq.d.ts +1 -3
  246. package/locales/sq.js +4 -2
  247. package/locales/sr-cyrl.d.ts +1 -3
  248. package/locales/sr-cyrl.js +16 -15
  249. package/locales/sr.d.ts +1 -3
  250. package/locales/sr.js +185 -2
  251. package/locales/ss.d.ts +1 -3
  252. package/locales/ss.js +4 -2
  253. package/locales/sv-fi.d.ts +1 -3
  254. package/locales/sv-fi.js +7 -9
  255. package/locales/sv.d.ts +1 -3
  256. package/locales/sv.js +110 -2
  257. package/locales/sw.d.ts +1 -3
  258. package/locales/sw.js +4 -2
  259. package/locales/ta.d.ts +1 -3
  260. package/locales/ta.js +4 -2
  261. package/locales/te.d.ts +1 -3
  262. package/locales/te.js +4 -2
  263. package/locales/tet.d.ts +1 -3
  264. package/locales/tet.js +5 -4
  265. package/locales/tg.d.ts +1 -3
  266. package/locales/tg.js +34 -35
  267. package/locales/th.d.ts +1 -3
  268. package/locales/th.js +4 -2
  269. package/locales/tk.d.ts +1 -3
  270. package/locales/tk.js +5 -4
  271. package/locales/tl-ph.d.ts +1 -3
  272. package/locales/tl-ph.js +4 -2
  273. package/locales/tlh.d.ts +1 -3
  274. package/locales/tlh.js +5 -2
  275. package/locales/tr.d.ts +1 -3
  276. package/locales/tr.js +5 -4
  277. package/locales/tzl.d.ts +1 -3
  278. package/locales/tzl.js +4 -2
  279. package/locales/tzm-latn.d.ts +1 -3
  280. package/locales/tzm-latn.js +9 -9
  281. package/locales/tzm.d.ts +1 -3
  282. package/locales/tzm.js +107 -2
  283. package/locales/ug-cn.d.ts +1 -3
  284. package/locales/ug-cn.js +4 -2
  285. package/locales/uk.d.ts +1 -3
  286. package/locales/uk.js +37 -32
  287. package/locales/ur.d.ts +1 -3
  288. package/locales/ur.js +4 -2
  289. package/locales/uz-latn.d.ts +1 -3
  290. package/locales/uz-latn.js +9 -9
  291. package/locales/uz.d.ts +1 -3
  292. package/locales/uz.js +107 -2
  293. package/locales/vi.d.ts +1 -3
  294. package/locales/vi.js +4 -2
  295. package/locales/x-pseudo.d.ts +1 -3
  296. package/locales/x-pseudo.js +5 -4
  297. package/locales/yo.d.ts +1 -3
  298. package/locales/yo.js +4 -2
  299. package/locales/zh-cn.d.ts +1 -3
  300. package/locales/zh-cn.js +7 -9
  301. package/locales/zh-hk.d.ts +1 -3
  302. package/locales/zh-hk.js +7 -9
  303. package/locales/zh-mo.d.ts +1 -3
  304. package/locales/zh-mo.js +7 -9
  305. package/locales/zh-tw.d.ts +1 -3
  306. package/locales/zh-tw.js +7 -9
  307. package/locales/zh.d.ts +1 -4
  308. package/locales/zh.js +128 -2
  309. package/package.json +29 -23
  310. package/plugins/advancedFormat/index.d.ts +1 -3
  311. package/plugins/advancedFormat/index.js +4 -6
  312. package/plugins/advancedParse/index.d.ts +1 -3
  313. package/plugins/advancedParse/index.js +21 -20
  314. package/plugins/calendar/index.d.ts +2 -4
  315. package/plugins/calendar/index.js +1 -2
  316. package/plugins/dayOfYear/index.d.ts +1 -2
  317. package/plugins/dayOfYear/index.js +1 -2
  318. package/plugins/duration/index.d.ts +78 -0
  319. package/plugins/duration/index.js +477 -0
  320. package/plugins/isBetween/index.d.ts +1 -2
  321. package/plugins/isBetween/index.js +2 -3
  322. package/plugins/isLeapYear/index.d.ts +1 -2
  323. package/plugins/isLeapYear/index.js +1 -2
  324. package/plugins/isSameOrAfter/index.d.ts +1 -2
  325. package/plugins/isSameOrAfter/index.js +1 -2
  326. package/plugins/isSameOrBefore/index.d.ts +1 -2
  327. package/plugins/isSameOrBefore/index.js +1 -2
  328. package/plugins/isToday/index.d.ts +1 -2
  329. package/plugins/isToday/index.js +2 -3
  330. package/plugins/isTomorrow/index.d.ts +1 -2
  331. package/plugins/isTomorrow/index.js +2 -3
  332. package/plugins/isYesterday/index.d.ts +1 -2
  333. package/plugins/isYesterday/index.js +2 -3
  334. package/plugins/isoWeek/index.d.ts +1 -3
  335. package/plugins/isoWeek/index.js +13 -25
  336. package/plugins/locale/index.d.ts +103 -3
  337. package/plugins/locale/index.js +140 -6
  338. package/plugins/localeData/index.d.ts +1 -3
  339. package/plugins/localeData/index.js +18 -11
  340. package/plugins/localizedFormat/index.d.ts +1 -3
  341. package/plugins/localizedFormat/index.js +5 -10
  342. package/plugins/localizedParse/index.d.ts +1 -3
  343. package/plugins/localizedParse/index.js +40 -22
  344. package/plugins/minMax/index.d.ts +1 -2
  345. package/plugins/minMax/index.js +2 -3
  346. package/plugins/objectSupport/index.d.ts +1 -3
  347. package/plugins/objectSupport/index.js +33 -38
  348. package/plugins/pluralGetSet/index.d.ts +1 -3
  349. package/plugins/pluralGetSet/index.js +1 -2
  350. package/plugins/quarterOfYear/index.d.ts +1 -3
  351. package/plugins/quarterOfYear/index.js +11 -18
  352. package/plugins/relativeTime/index.d.ts +32 -44
  353. package/plugins/relativeTime/index.js +124 -91
  354. package/plugins/timezone/index.d.ts +6 -0
  355. package/plugins/timezone/index.js +456 -0
  356. package/plugins/toArray/index.d.ts +1 -2
  357. package/plugins/toArray/index.js +1 -2
  358. package/plugins/toObject/index.d.ts +1 -2
  359. package/plugins/toObject/index.js +1 -2
  360. package/plugins/utc/index.d.ts +1 -2
  361. package/plugins/utc/index.js +37 -39
  362. package/plugins/week/index.d.ts +1 -3
  363. package/plugins/week/index.js +17 -27
  364. package/chunks/B5f9poqo.js +0 -120
  365. package/chunks/BDssPbM_.js +0 -106
  366. package/chunks/BXRGSAJG.js +0 -128
  367. package/chunks/BeVgU2nj.js +0 -188
  368. package/chunks/BtmEtAW3.js +0 -43
  369. package/chunks/CQ57zhVp.js +0 -106
  370. package/chunks/CQJ0-ZuR.js +0 -106
  371. package/chunks/CWqzr5E5.js +0 -108
  372. package/chunks/Cg4ZI9v8.js +0 -180
  373. package/chunks/CoBtJ4c1.js +0 -144
  374. package/chunks/D009Z-ld.js +0 -109
  375. package/chunks/DMtTiWuY.js +0 -127
  376. package/chunks/Dixb5KKs.js +0 -116
  377. package/chunks/DjY7KvwG.js +0 -28
  378. package/chunks/GjKpN6U-.js +0 -135
  379. package/chunks/St35qgL0.d.ts +0 -103
  380. package/chunks/br7kModF.js +0 -110
  381. package/chunks/l2Rxo2H0.js +0 -106
  382. package/chunks/tfkJ5D3p.js +0 -115
@@ -1,7 +1,7 @@
1
- import { constants_default } from "../../chunks/Y32qdU_5.js";
2
- import { isUndefined } from "../../chunks/Cb5SvF6r.js";
3
- import { createInstanceFromExist } from "../../chunks/DXHbH1CI.js";
4
- import { padStart } from "../../chunks/BRRrAbUl.js";
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 inputLimited = input.slice(0, 2);
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
- const modifiedEsday = newEsday.isoWeek(parsedIsoWeek).isoWeekday(weekStart);
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
- const modifiedEsday = newEsday.isoWeekday(newIsoWeekday);
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 yearStartWeekday = yearStartDate.day();
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
- const additionalTokens = {
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 { isoWeek_default as default };
228
+ export { isoWeekPlugin as default };
@@ -1,4 +1,104 @@
1
- import "../../chunks/DqhiVwLi.js";
2
- import "../../chunks/MtjcOKi-.js";
3
- import { Calendar, CalendarPartial, CalendarSpecVal, CalendarSpecValFunction, DayNames, DayNamesStandaloneFormat, Locale, LocaleFormatKeys, MonthNames, MonthNamesFunction, MonthNamesStandaloneFormat, RelativeTimeElementFunction, RelativeTimeKeys, cloneLocale, localePlugin, setLocaleProperty } from "../../chunks/St35qgL0.js";
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 };
@@ -1,7 +1,141 @@
1
- import "../../chunks/Y32qdU_5.js";
2
- import "../../chunks/Cb5SvF6r.js";
3
- import "../../chunks/DjY7KvwG.js";
4
- import "../../chunks/tfkJ5D3p.js";
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
- export { cloneLocale, locale_default as default, setLocaleProperty };
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/DqhiVwLi.js";
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
- const formatsArray = locale.formats;
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
- if (date !== void 0) result = calendarEntry.call(date, now);
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 relativeTimeArray = locale.relativeTime;
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
- const locale = this.localeObject();
133
- return createLocaleDataObject(locale);
142
+ return createLocaleDataObject(this.localeObject());
134
143
  };
135
144
  dayFactory.localeData = (localeName) => {
136
- const locale = localeName !== void 0 ? dayFactory.getLocale(localeName) : dayFactory.getLocale(dayFactory.locale());
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 { localeData_default as default };
155
+ export { localeDataPlugin as default };
@@ -1,8 +1,6 @@
1
- import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
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 { isArray, isString } from "../../chunks/Cb5SvF6r.js";
2
- import { padNumberWithLeadingZeros } from "../../chunks/BRRrAbUl.js";
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
- const parseForUseFormat = weekdays.isFormat;
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
- const parseForUseFormat = months.isFormat ?? MONTHS_IN_FORMAT;
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 { localizedFormat_default as default };
83
+ export { localizedFormatPlugin as default };
@@ -1,8 +1,6 @@
1
- import { EsDayPlugin } from "../../chunks/DqhiVwLi.js";
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 { isArray, isString, isUndefined } from "../../chunks/Cb5SvF6r.js";
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
- function addHour(parsedElements, input, _parseOptions) {
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
- function meridiemMatch(locale, input, isLowerCase) {
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
- function addAfternoon(isLowerCase, esday) {
52
+ const addAfternoon = (isLowerCase, esday) => {
42
53
  return function meridiemUpdater(parsedElements, input, parseOptions) {
43
54
  const localeName = parseOptions["locale"];
44
- const locale = esday.getLocale(localeName);
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
- function addDayOfMonthOrdinal(esday) {
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
- function addMonth(property, esday) {
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
- function replaceLocaleTokens(format, currentLocale) {
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
- matchWord,
159
- matchWord,
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") currentLocale = dayFactory.getLocale(arg2);
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 { localizedParse_default as default };
217
+ export { localizedParsePlugin as default };
@@ -1,5 +1,4 @@
1
- import { DateType, EsDayPlugin } from "../../chunks/DqhiVwLi.js";
2
- import "../../chunks/MtjcOKi-.js";
1
+ import { o as EsDayPlugin, r as DateType } from "../../chunks/CODi8AFH.js";
3
2
 
4
3
  //#region src/plugins/minMax/index.d.ts
5
4
  declare module 'esday' {