esday 0.4.1 → 0.6.2

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