esday 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +20 -2
  4. package/chunks/B5f9poqo.js +120 -0
  5. package/chunks/BDssPbM_.js +106 -0
  6. package/chunks/BRRrAbUl.js +56 -0
  7. package/chunks/BXRGSAJG.js +128 -0
  8. package/chunks/BeVgU2nj.js +188 -0
  9. package/chunks/BtmEtAW3.js +43 -0
  10. package/chunks/CQ57zhVp.js +106 -0
  11. package/chunks/CQJ0-ZuR.js +106 -0
  12. package/chunks/CWqzr5E5.js +108 -0
  13. package/chunks/Cb5SvF6r.js +25 -0
  14. package/chunks/Cg4ZI9v8.js +180 -0
  15. package/chunks/CoBtJ4c1.js +144 -0
  16. package/chunks/D009Z-ld.js +109 -0
  17. package/chunks/DMtTiWuY.js +127 -0
  18. package/chunks/DXHbH1CI.js +9 -0
  19. package/chunks/Dixb5KKs.js +116 -0
  20. package/chunks/DjY7KvwG.js +28 -0
  21. package/chunks/DqhiVwLi.d.ts +203 -0
  22. package/chunks/GjKpN6U-.js +135 -0
  23. package/chunks/MtjcOKi-.d.ts +6 -0
  24. package/chunks/St35qgL0.d.ts +103 -0
  25. package/chunks/Y32qdU_5.js +62 -0
  26. package/chunks/br7kModF.js +110 -0
  27. package/chunks/l2Rxo2H0.js +106 -0
  28. package/chunks/tfkJ5D3p.js +115 -0
  29. package/index.d.ts +3 -6
  30. package/index.js +556 -293
  31. package/locales/af.d.ts +8 -0
  32. package/locales/af.js +106 -0
  33. package/locales/am.d.ts +8 -0
  34. package/locales/am.js +106 -0
  35. package/locales/ar-dz.d.ts +11 -0
  36. package/locales/ar-dz.js +32 -0
  37. package/locales/ar-iq.d.ts +11 -0
  38. package/locales/ar-iq.js +14 -0
  39. package/locales/ar-kw.d.ts +11 -0
  40. package/locales/ar-kw.js +28 -0
  41. package/locales/ar-ly.d.ts +11 -0
  42. package/locales/ar-ly.js +14 -0
  43. package/locales/ar-ma.d.ts +11 -0
  44. package/locales/ar-ma.js +29 -0
  45. package/locales/ar-sa.d.ts +11 -0
  46. package/locales/ar-sa.js +29 -0
  47. package/locales/ar-tn.d.ts +11 -0
  48. package/locales/ar-tn.js +29 -0
  49. package/locales/ar.d.ts +8 -0
  50. package/locales/ar.js +3 -0
  51. package/locales/az.d.ts +8 -0
  52. package/locales/az.js +106 -0
  53. package/locales/be.d.ts +8 -0
  54. package/locales/be.js +140 -0
  55. package/locales/bg.d.ts +8 -0
  56. package/locales/bg.js +125 -0
  57. package/locales/bi.d.ts +8 -0
  58. package/locales/bi.js +106 -0
  59. package/locales/bm.d.ts +8 -0
  60. package/locales/bm.js +106 -0
  61. package/locales/bn-bd.d.ts +11 -0
  62. package/locales/bn-bd.js +24 -0
  63. package/locales/bn.d.ts +8 -0
  64. package/locales/bn.js +3 -0
  65. package/locales/bo.d.ts +8 -0
  66. package/locales/bo.js +106 -0
  67. package/locales/br.d.ts +8 -0
  68. package/locales/br.js +179 -0
  69. package/locales/bs.d.ts +8 -0
  70. package/locales/bs.js +128 -0
  71. package/locales/ca.d.ts +8 -0
  72. package/locales/ca.js +143 -0
  73. package/locales/cs.d.ts +8 -0
  74. package/locales/cs.js +182 -0
  75. package/locales/cv.d.ts +8 -0
  76. package/locales/cv.js +106 -0
  77. package/locales/cy.d.ts +8 -0
  78. package/locales/cy.js +106 -0
  79. package/locales/da.d.ts +8 -0
  80. package/locales/da.js +106 -0
  81. package/locales/de-at.d.ts +11 -0
  82. package/locales/de-at.js +44 -0
  83. package/locales/de-ch.d.ts +11 -0
  84. package/locales/de-ch.js +14 -0
  85. package/locales/de.d.ts +8 -0
  86. package/locales/de.js +3 -0
  87. package/locales/dv.d.ts +8 -0
  88. package/locales/dv.js +106 -0
  89. package/locales/el.d.ts +8 -0
  90. package/locales/el.js +115 -0
  91. package/locales/en-au.d.ts +11 -0
  92. package/locales/en-au.js +27 -0
  93. package/locales/en-ca.d.ts +11 -0
  94. package/locales/en-ca.js +27 -0
  95. package/locales/en-gb.d.ts +13 -0
  96. package/locales/en-gb.js +28 -0
  97. package/locales/en-ie.d.ts +11 -0
  98. package/locales/en-ie.js +26 -0
  99. package/locales/en-il.d.ts +11 -0
  100. package/locales/en-il.js +28 -0
  101. package/locales/en-in.d.ts +11 -0
  102. package/locales/en-in.js +26 -0
  103. package/locales/en-nz.d.ts +11 -0
  104. package/locales/en-nz.js +28 -0
  105. package/locales/en-sg.d.ts +11 -0
  106. package/locales/en-sg.js +28 -0
  107. package/locales/en-tt.d.ts +11 -0
  108. package/locales/en-tt.js +28 -0
  109. package/locales/en-us.d.ts +11 -0
  110. package/locales/en-us.js +13 -0
  111. package/locales/en.d.ts +7 -5
  112. package/locales/en.js +3 -1
  113. package/locales/eo.d.ts +8 -0
  114. package/locales/eo.js +106 -0
  115. package/locales/es-do.d.ts +11 -0
  116. package/locales/es-do.js +27 -0
  117. package/locales/es-mx.d.ts +11 -0
  118. package/locales/es-mx.js +15 -0
  119. package/locales/es-pr.d.ts +11 -0
  120. package/locales/es-pr.js +18 -0
  121. package/locales/es-us.d.ts +11 -0
  122. package/locales/es-us.js +14 -0
  123. package/locales/es.d.ts +8 -0
  124. package/locales/es.js +3 -0
  125. package/locales/et.d.ts +8 -0
  126. package/locales/et.js +142 -0
  127. package/locales/eu.d.ts +8 -0
  128. package/locales/eu.js +106 -0
  129. package/locales/fa.d.ts +8 -0
  130. package/locales/fa.js +106 -0
  131. package/locales/fi.d.ts +8 -0
  132. package/locales/fi.js +165 -0
  133. package/locales/fil.d.ts +8 -0
  134. package/locales/fil.js +106 -0
  135. package/locales/fo.d.ts +8 -0
  136. package/locales/fo.js +106 -0
  137. package/locales/fr-ca.d.ts +11 -0
  138. package/locales/fr-ca.js +18 -0
  139. package/locales/fr-ch.d.ts +11 -0
  140. package/locales/fr-ch.js +18 -0
  141. package/locales/fr.d.ts +8 -0
  142. package/locales/fr.js +3 -0
  143. package/locales/fy.d.ts +8 -0
  144. package/locales/fy.js +106 -0
  145. package/locales/ga.d.ts +8 -0
  146. package/locales/ga.js +106 -0
  147. package/locales/gd.d.ts +8 -0
  148. package/locales/gd.js +106 -0
  149. package/locales/gl.d.ts +8 -0
  150. package/locales/gl.js +116 -0
  151. package/locales/gom-deva.d.ts +8 -0
  152. package/locales/gom-deva.js +146 -0
  153. package/locales/gom-latn.d.ts +8 -0
  154. package/locales/gom-latn.js +146 -0
  155. package/locales/gu.d.ts +8 -0
  156. package/locales/gu.js +106 -0
  157. package/locales/he.d.ts +8 -0
  158. package/locales/he.js +129 -0
  159. package/locales/hi.d.ts +8 -0
  160. package/locales/hi.js +125 -0
  161. package/locales/hr.d.ts +8 -0
  162. package/locales/hr.js +189 -0
  163. package/locales/ht.d.ts +8 -0
  164. package/locales/ht.js +106 -0
  165. package/locales/hu.d.ts +8 -0
  166. package/locales/hu.js +140 -0
  167. package/locales/hy-am.d.ts +8 -0
  168. package/locales/hy-am.js +127 -0
  169. package/locales/id.d.ts +8 -0
  170. package/locales/id.js +106 -0
  171. package/locales/is.d.ts +8 -0
  172. package/locales/is.js +155 -0
  173. package/locales/it-ch.d.ts +11 -0
  174. package/locales/it-ch.js +32 -0
  175. package/locales/it.d.ts +8 -0
  176. package/locales/it.js +3 -0
  177. package/locales/ja.d.ts +15 -0
  178. package/locales/ja.js +109 -0
  179. package/locales/jv.d.ts +8 -0
  180. package/locales/jv.js +106 -0
  181. package/locales/ka.d.ts +8 -0
  182. package/locales/ka.js +126 -0
  183. package/locales/kk.d.ts +8 -0
  184. package/locales/kk.js +106 -0
  185. package/locales/km.d.ts +8 -0
  186. package/locales/km.js +106 -0
  187. package/locales/kn.d.ts +8 -0
  188. package/locales/kn.js +106 -0
  189. package/locales/ko.d.ts +8 -0
  190. package/locales/ko.js +105 -0
  191. package/locales/ku.d.ts +8 -0
  192. package/locales/ku.js +119 -0
  193. package/locales/ky.d.ts +8 -0
  194. package/locales/ky.js +106 -0
  195. package/locales/lb.d.ts +8 -0
  196. package/locales/lb.js +166 -0
  197. package/locales/lo.d.ts +8 -0
  198. package/locales/lo.js +105 -0
  199. package/locales/lt.d.ts +8 -0
  200. package/locales/lt.js +106 -0
  201. package/locales/lv.d.ts +8 -0
  202. package/locales/lv.js +106 -0
  203. package/locales/me.d.ts +8 -0
  204. package/locales/me.js +129 -0
  205. package/locales/mi.d.ts +8 -0
  206. package/locales/mi.js +106 -0
  207. package/locales/mk.d.ts +8 -0
  208. package/locales/mk.js +117 -0
  209. package/locales/ml.d.ts +8 -0
  210. package/locales/ml.js +109 -0
  211. package/locales/mn.d.ts +8 -0
  212. package/locales/mn.js +106 -0
  213. package/locales/mr.d.ts +8 -0
  214. package/locales/mr.js +215 -0
  215. package/locales/ms-my.d.ts +11 -0
  216. package/locales/ms-my.js +14 -0
  217. package/locales/ms.d.ts +8 -0
  218. package/locales/ms.js +3 -0
  219. package/locales/mt.d.ts +8 -0
  220. package/locales/mt.js +106 -0
  221. package/locales/my.d.ts +8 -0
  222. package/locales/my.js +132 -0
  223. package/locales/nb.d.ts +8 -0
  224. package/locales/nb.js +106 -0
  225. package/locales/ne.d.ts +8 -0
  226. package/locales/ne.js +106 -0
  227. package/locales/nl-be.d.ts +11 -0
  228. package/locales/nl-be.js +18 -0
  229. package/locales/nl.d.ts +8 -0
  230. package/locales/nl.js +3 -0
  231. package/locales/nn.d.ts +8 -0
  232. package/locales/nn.js +106 -0
  233. package/locales/oc-lnc.d.ts +8 -0
  234. package/locales/oc-lnc.js +126 -0
  235. package/locales/pa-in.d.ts +8 -0
  236. package/locales/pa-in.js +123 -0
  237. package/locales/pl.d.ts +8 -0
  238. package/locales/pl.js +159 -0
  239. package/locales/pt-br.d.ts +11 -0
  240. package/locales/pt-br.js +53 -0
  241. package/locales/pt.d.ts +8 -0
  242. package/locales/pt.js +3 -0
  243. package/locales/rn.d.ts +8 -0
  244. package/locales/rn.js +106 -0
  245. package/locales/ro.d.ts +8 -0
  246. package/locales/ro.js +106 -0
  247. package/locales/ru.d.ts +15 -0
  248. package/locales/ru.js +236 -0
  249. package/locales/rw.d.ts +8 -0
  250. package/locales/rw.js +106 -0
  251. package/locales/sd.d.ts +8 -0
  252. package/locales/sd.js +106 -0
  253. package/locales/se.d.ts +8 -0
  254. package/locales/se.js +106 -0
  255. package/locales/si.d.ts +8 -0
  256. package/locales/si.js +106 -0
  257. package/locales/sk.d.ts +8 -0
  258. package/locales/sk.js +162 -0
  259. package/locales/sl.d.ts +8 -0
  260. package/locales/sl.js +171 -0
  261. package/locales/sq.d.ts +8 -0
  262. package/locales/sq.js +106 -0
  263. package/locales/sr-cyrl.d.ts +11 -0
  264. package/locales/sr-cyrl.js +173 -0
  265. package/locales/sr.d.ts +8 -0
  266. package/locales/sr.js +3 -0
  267. package/locales/ss.d.ts +8 -0
  268. package/locales/ss.js +108 -0
  269. package/locales/sv-fi.d.ts +11 -0
  270. package/locales/sv-fi.js +27 -0
  271. package/locales/sv.d.ts +8 -0
  272. package/locales/sv.js +3 -0
  273. package/locales/sw.d.ts +8 -0
  274. package/locales/sw.js +106 -0
  275. package/locales/ta.d.ts +8 -0
  276. package/locales/ta.js +137 -0
  277. package/locales/te.d.ts +8 -0
  278. package/locales/te.js +109 -0
  279. package/locales/tet.d.ts +8 -0
  280. package/locales/tet.js +110 -0
  281. package/locales/tg.d.ts +8 -0
  282. package/locales/tg.js +128 -0
  283. package/locales/th.d.ts +8 -0
  284. package/locales/th.js +106 -0
  285. package/locales/tk.d.ts +8 -0
  286. package/locales/tk.js +134 -0
  287. package/locales/tl-ph.d.ts +8 -0
  288. package/locales/tl-ph.js +106 -0
  289. package/locales/tlh.d.ts +8 -0
  290. package/locales/tlh.js +152 -0
  291. package/locales/tr.d.ts +8 -0
  292. package/locales/tr.js +134 -0
  293. package/locales/tzl.d.ts +8 -0
  294. package/locales/tzl.js +123 -0
  295. package/locales/tzm-latn.d.ts +11 -0
  296. package/locales/tzm-latn.js +68 -0
  297. package/locales/tzm.d.ts +8 -0
  298. package/locales/tzm.js +3 -0
  299. package/locales/ug-cn.d.ts +8 -0
  300. package/locales/ug-cn.js +111 -0
  301. package/locales/uk.d.ts +8 -0
  302. package/locales/uk.js +194 -0
  303. package/locales/ur.d.ts +8 -0
  304. package/locales/ur.js +108 -0
  305. package/locales/uz-latn.d.ts +11 -0
  306. package/locales/uz-latn.js +68 -0
  307. package/locales/uz.d.ts +8 -0
  308. package/locales/uz.js +3 -0
  309. package/locales/vi.d.ts +8 -0
  310. package/locales/vi.js +106 -0
  311. package/locales/x-pseudo.d.ts +8 -0
  312. package/locales/x-pseudo.js +110 -0
  313. package/locales/yo.d.ts +8 -0
  314. package/locales/yo.js +106 -0
  315. package/locales/zh-cn.d.ts +11 -0
  316. package/locales/zh-cn.js +14 -0
  317. package/locales/zh-hk.d.ts +11 -0
  318. package/locales/zh-hk.js +23 -0
  319. package/locales/zh-mo.d.ts +11 -0
  320. package/locales/zh-mo.js +23 -0
  321. package/locales/zh-tw.d.ts +11 -0
  322. package/locales/zh-tw.js +23 -0
  323. package/locales/zh.d.ts +13 -4
  324. package/locales/zh.js +2 -63
  325. package/package.json +51 -25
  326. package/plugins/advancedFormat/index.d.ts +8 -0
  327. package/plugins/advancedFormat/index.js +20 -0
  328. package/plugins/advancedParse/index.d.ts +8 -0
  329. package/plugins/advancedParse/index.js +406 -0
  330. package/plugins/calendar/index.d.ts +14 -0
  331. package/plugins/calendar/index.js +33 -0
  332. package/plugins/dayOfYear/index.d.ts +13 -0
  333. package/plugins/dayOfYear/index.js +12 -0
  334. package/plugins/isBetween/index.d.ts +23 -0
  335. package/plugins/isBetween/index.js +16 -0
  336. package/plugins/isLeapYear/index.d.ts +12 -0
  337. package/plugins/isLeapYear/index.js +11 -0
  338. package/plugins/isSameOrAfter/index.d.ts +12 -0
  339. package/plugins/isSameOrAfter/index.js +10 -0
  340. package/plugins/isSameOrBefore/index.d.ts +12 -0
  341. package/plugins/isSameOrBefore/index.js +10 -0
  342. package/plugins/isToday/index.d.ts +8 -6
  343. package/plugins/isToday/index.js +10 -6
  344. package/plugins/isTomorrow/index.d.ts +12 -0
  345. package/plugins/isTomorrow/index.js +14 -0
  346. package/plugins/isYesterday/index.d.ts +12 -0
  347. package/plugins/isYesterday/index.js +14 -0
  348. package/plugins/isoWeek/index.d.ts +21 -0
  349. package/plugins/isoWeek/index.js +240 -0
  350. package/plugins/locale/index.d.ts +4 -75
  351. package/plugins/locale/index.js +6 -69
  352. package/plugins/localeData/index.d.ts +8 -0
  353. package/plugins/localeData/index.js +148 -0
  354. package/plugins/localizedFormat/index.d.ts +8 -0
  355. package/plugins/localizedFormat/index.js +88 -0
  356. package/plugins/localizedParse/index.d.ts +8 -0
  357. package/plugins/localizedParse/index.js +199 -0
  358. package/plugins/minMax/index.d.ts +13 -0
  359. package/plugins/minMax/index.js +22 -0
  360. package/plugins/objectSupport/index.d.ts +8 -0
  361. package/plugins/objectSupport/index.js +104 -0
  362. package/plugins/pluralGetSet/index.d.ts +20 -0
  363. package/plugins/pluralGetSet/index.js +16 -0
  364. package/plugins/quarterOfYear/index.d.ts +16 -0
  365. package/plugins/quarterOfYear/index.js +58 -0
  366. package/plugins/relativeTime/index.d.ts +59 -0
  367. package/plugins/relativeTime/index.js +154 -0
  368. package/plugins/toArray/index.d.ts +12 -0
  369. package/plugins/toArray/index.js +18 -0
  370. package/plugins/toObject/index.d.ts +20 -0
  371. package/plugins/toObject/index.js +18 -0
  372. package/plugins/utc/index.d.ts +14 -17
  373. package/plugins/utc/index.js +191 -37
  374. package/plugins/week/index.d.ts +21 -0
  375. package/plugins/week/index.js +360 -0
  376. package/EsDay-KXQgnL1r.d.ts +0 -89
  377. package/chunk-MLKGABMK.js +0 -7
  378. package/chunk-NUV73YDM.js +0 -60
  379. package/chunk-SQBPUYUY.js +0 -140
  380. package/plugins/customParseFormat/index.d.ts +0 -5
  381. package/plugins/customParseFormat/index.js +0 -159
package/index.js CHANGED
@@ -1,310 +1,573 @@
1
- import { constant_exports, getUnitInDate, prettyUnit, setUnitInDate, isObject, createInstanceFromExist, padZoneStr, isUndefined, isEmptyObject, padStart } from './chunk-SQBPUYUY.js';
1
+ import { constants_default } from "./chunks/Y32qdU_5.js";
2
+ import { isArray, isEmptyObject, isObject, isUndefined, isValidDate } from "./chunks/Cb5SvF6r.js";
3
+ import { normalizeUnit, normalizeUnitWithPlurals } from "./chunks/DjY7KvwG.js";
4
+ import { getUnitInDate, prettyUnitsDate, setUnitInDate } from "./chunks/BtmEtAW3.js";
5
+ import { createInstanceFromExist } from "./chunks/DXHbH1CI.js";
6
+ import { padStart, padZoneStr } from "./chunks/BRRrAbUl.js";
2
7
 
3
- // src/core/Impl/add.ts
4
- function addImpl(that, number, units) {
5
- const $d = that["$d"];
6
- const unit = prettyUnit(units);
7
- const instanceFactorySet = (multiplier) => {
8
- const newInstance = that.clone();
9
- newInstance["$d"].setDate($d.getDate() + Math.round(multiplier * number));
10
- return newInstance;
11
- };
12
- if (unit === constant_exports.MONTH) {
13
- return that.set("month", that.get("month") + number);
14
- }
15
- if (unit === constant_exports.YEAR) {
16
- return that.set("year", that.get("year") + number);
17
- }
18
- if (unit === constant_exports.DATE || unit === constant_exports.DAY) {
19
- return instanceFactorySet(1);
20
- }
21
- if (unit === constant_exports.WEEK) {
22
- return instanceFactorySet(7);
23
- }
24
- const step = {
25
- minute: 60 * 1e3,
26
- hour: 60 * 60 * 1e3,
27
- second: 1e3
28
- }[unit] || 1;
29
- const nextTimeStamp = $d.getTime() + number * step;
30
- return createInstanceFromExist(new Date(nextTimeStamp), that);
8
+ //#region rolldown:runtime
9
+ var __create = Object.create;
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __commonJS = (cb, mod) => function() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+
33
+ //#endregion
34
+ //#region src/core/Impl/add.ts
35
+ function addImpl(that, value, units) {
36
+ const $d = that["$d"];
37
+ const unit = normalizeUnitWithPlurals(units);
38
+ const instanceFactorySet = (multiplier) => {
39
+ const newInstance = that.clone();
40
+ newInstance["$d"].setDate($d.getDate() + Math.round(multiplier * value));
41
+ return newInstance;
42
+ };
43
+ switch (normalizeUnitWithPlurals(unit)) {
44
+ case constants_default.YEAR: return that.set("year", that.get("year") + value);
45
+ case constants_default.MONTH: return that.set("month", that.get("month") + value);
46
+ case constants_default.WEEK: return instanceFactorySet(7);
47
+ case constants_default.DAY:
48
+ case constants_default.DAY_OF_MONTH: return instanceFactorySet(1);
49
+ case constants_default.HOUR:
50
+ case constants_default.MIN:
51
+ case constants_default.SECOND:
52
+ case constants_default.MS: {
53
+ const step = {
54
+ minute: 60 * 1e3,
55
+ hour: 3600 * 1e3,
56
+ second: 1e3
57
+ }[unit] || 1;
58
+ const nextTimeStamp = $d.getTime() + value * step;
59
+ return createInstanceFromExist(new Date(nextTimeStamp), that);
60
+ }
61
+ default: return that.clone();
62
+ }
31
63
  }
32
64
 
33
- // src/core/Impl/format.ts
34
- function formatImpl(that, formatStr) {
35
- if (!that.isValid())
36
- return constant_exports.INVALID_DATE_STRING;
37
- const str = formatStr || constant_exports.FORMAT_DEFAULT;
38
- const get$H = (num) => padStart(that.hour() % 12 || 12, num, "0");
39
- const meridiemFunc = (hour, _minute, isLowercase) => {
40
- const m = hour < 12 ? "AM" : "PM";
41
- return isLowercase ? m.toLowerCase() : m;
42
- };
43
- const zoneStr = padZoneStr(that.utcOffset());
44
- const $year = that.year();
45
- const $month = that.month();
46
- const $date = that.date();
47
- const $day = that.day();
48
- const $hour = that.hour();
49
- const $minute = that.minute();
50
- const $second = that.second();
51
- const $millisecond = that.millisecond();
52
- const matches = (match) => {
53
- switch (match) {
54
- case "YY":
55
- return String($year).slice(-2);
56
- case "YYYY":
57
- return padStart($year, 4, "0");
58
- case "M":
59
- return $month + 1;
60
- case "MM":
61
- return padStart($month + 1, 2, "0");
62
- case "D":
63
- return $date;
64
- case "DD":
65
- return padStart($date, 2, "0");
66
- case "d":
67
- return String($day);
68
- case "H":
69
- return String($hour);
70
- case "HH":
71
- return padStart($hour, 2, "0");
72
- case "h":
73
- return get$H(1);
74
- case "hh":
75
- return get$H(2);
76
- case "a":
77
- return meridiemFunc($hour, $minute, true);
78
- case "A":
79
- return meridiemFunc($hour, $minute, false);
80
- case "m":
81
- return String($minute);
82
- case "mm":
83
- return padStart($minute, 2, "0");
84
- case "s":
85
- return String($second);
86
- case "ss":
87
- return padStart($second, 2, "0");
88
- case "SSS":
89
- return padStart($millisecond, 3, "0");
90
- case "Z":
91
- return zoneStr;
92
- }
93
- return null;
94
- };
95
- return str.replace(constant_exports.REGEX_FORMAT, (match, $1) => $1 || matches(match));
65
+ //#endregion
66
+ //#region src/core/Impl/diff.ts
67
+ /**
68
+ * get difference between 2 dates as months.
69
+ * As implemented by moment.js, the algorithm is optimized to ensure that two months
70
+ * with the same date are always a whole number apart.
71
+ * @param a - date 1
72
+ * @param b - date 2
73
+ * @returns b - a in months
74
+ */
75
+ function monthDiff(a, b) {
76
+ if (a.date() < b.date()) return -monthDiff(b, a);
77
+ const wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
78
+ const anchor = a.clone().add(wholeMonthDiff, constants_default.MONTH);
79
+ const c = b.valueOf() - anchor.valueOf() < 0;
80
+ const anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), constants_default.MONTH);
81
+ return +(-(wholeMonthDiff + (b.valueOf() - anchor.valueOf()) / (c ? anchor.valueOf() - anchor2.valueOf() : anchor2.valueOf() - anchor.valueOf())) || 0);
82
+ }
83
+ /**
84
+ * Drop fractional part of a number.
85
+ * @param n - number to inspect
86
+ * @returns n without fractional part
87
+ */
88
+ function absFloor(n) {
89
+ return n < 0 ? Math.ceil(n) : Math.floor(n);
90
+ }
91
+ function diffImpl(that, date, units, asFloat = false) {
92
+ const diffInMs = that.valueOf() - date.valueOf();
93
+ const diffInMonths = monthDiff(that, date);
94
+ const zoneDelta = (that.utcOffset() - date.utcOffset()) * constants_default.MILLISECONDS_A_MINUTE;
95
+ let result;
96
+ if (isUndefined(units)) result = diffInMs;
97
+ else {
98
+ const unit = normalizeUnitWithPlurals(units);
99
+ switch (unit) {
100
+ case constants_default.YEAR:
101
+ result = diffInMonths / 12;
102
+ break;
103
+ case constants_default.MONTH:
104
+ result = diffInMonths;
105
+ break;
106
+ case constants_default.QUARTER:
107
+ result = diffInMonths / 3;
108
+ break;
109
+ case constants_default.WEEK:
110
+ result = (diffInMs + zoneDelta) / constants_default.MILLISECONDS_A_WEEK;
111
+ break;
112
+ case constants_default.DAY:
113
+ result = (diffInMs + zoneDelta) / constants_default.MILLISECONDS_A_DAY;
114
+ break;
115
+ case constants_default.HOUR:
116
+ result = diffInMs / constants_default.MILLISECONDS_A_HOUR;
117
+ break;
118
+ case constants_default.MIN:
119
+ result = diffInMs / constants_default.MILLISECONDS_A_MINUTE;
120
+ break;
121
+ case constants_default.SECOND:
122
+ result = diffInMs / constants_default.MILLISECONDS_A_SECOND;
123
+ break;
124
+ default:
125
+ result = diffInMs;
126
+ break;
127
+ }
128
+ }
129
+ return asFloat ? result : absFloor(result);
96
130
  }
97
131
 
98
- // src/core/Impl/startOf.ts
99
- function startOfImpl(that, unit, reverse = false) {
100
- const result = that.clone();
101
- const setterFunc = result["$set"];
102
- const instanceFactorySet = (method, slice) => {
103
- const argumentStart = [0, 0, 0, 0];
104
- const argumentEnd = [23, 59, 59, 999];
105
- const argument = reverse ? argumentEnd.slice(slice) : argumentStart.slice(slice);
106
- setterFunc.call(result, method, argument);
107
- };
108
- const instanceFactory = (date, month) => {
109
- setterFunc.call(result, constant_exports.MONTH, [month, date]);
110
- };
111
- const $month = result.month();
112
- const $date = result.date();
113
- const $day = result.day();
114
- switch (prettyUnit(unit)) {
115
- case constant_exports.YEAR:
116
- reverse ? instanceFactory(31, 11) : instanceFactory(1, 0);
117
- instanceFactorySet(constant_exports.HOUR, 0);
118
- break;
119
- case constant_exports.MONTH:
120
- reverse ? instanceFactory(0, $month + 1) : instanceFactory(1, $month);
121
- instanceFactorySet(constant_exports.HOUR, 0);
122
- break;
123
- case constant_exports.WEEK: {
124
- const weekStart = constant_exports.INDEX_MONDAY;
125
- const diff = ($day < weekStart ? $day + 7 : $day) - weekStart;
126
- instanceFactory(reverse ? $date + (6 - diff) : $date - diff, $month);
127
- instanceFactorySet(constant_exports.HOUR, 0);
128
- break;
129
- }
130
- case constant_exports.DAY:
131
- case constant_exports.DATE:
132
- instanceFactorySet(constant_exports.HOUR, 0);
133
- break;
134
- case constant_exports.HOUR:
135
- instanceFactorySet(constant_exports.MIN, 1);
136
- break;
137
- case constant_exports.MIN:
138
- instanceFactorySet(constant_exports.SECOND, 2);
139
- break;
140
- case constant_exports.SECOND:
141
- instanceFactorySet(constant_exports.MS, 3);
142
- break;
143
- }
144
- return result;
132
+ //#endregion
133
+ //#region src/core/Impl/format.ts
134
+ const formattingSeparatorsRegex = "\\[([^\\]]+)\\]";
135
+ let formattingTokensRegex;
136
+ const formatTokensDefinitions = {
137
+ YY: (sourceDate) => padStart(sourceDate.year(), 2, "0").slice(-2),
138
+ YYYY: (sourceDate) => padStart(sourceDate.year(), 4, "0"),
139
+ M: (sourceDate) => String(sourceDate.month() + 1),
140
+ MM: (sourceDate) => padStart(sourceDate.month() + 1, 2, "0"),
141
+ D: (sourceDate) => String(sourceDate.date()),
142
+ DD: (sourceDate) => padStart(sourceDate.date(), 2, "0"),
143
+ H: (sourceDate) => String(sourceDate.hour()),
144
+ HH: (sourceDate) => padStart(sourceDate.hour(), 2, "0"),
145
+ m: (sourceDate) => String(sourceDate.minute()),
146
+ mm: (sourceDate) => padStart(sourceDate.minute(), 2, "0"),
147
+ s: (sourceDate) => String(sourceDate.second()),
148
+ ss: (sourceDate) => padStart(sourceDate.second(), 2, "0"),
149
+ SSS: (sourceDate) => padStart(sourceDate.millisecond(), 3, "0"),
150
+ Z: (sourceDate) => padZoneStr(sourceDate.utcOffset())
151
+ };
152
+ /**
153
+ * Compare 2 tokens for sorting.
154
+ * Longer token and upper case token are sorted to the top.
155
+ * As we sort here object keys, a and b can never be equal.
156
+ * @param a - token 1
157
+ * @param b - token 2
158
+ * @returns -1 (a<b), 0 (a==b), 1 (a>b)
159
+ */
160
+ function compareTokens(a, b) {
161
+ if (a.length < b.length) return 1;
162
+ if (a.length > b.length) return -1;
163
+ if (a < b) return 1;
164
+ return -1;
165
+ }
166
+ function formattingTokensRegexFromDefinitions() {
167
+ const tokenKeys = Object.keys(formatTokensDefinitions).sort(compareTokens);
168
+ formattingTokensRegex = new RegExp(`${formattingSeparatorsRegex}|${tokenKeys.join("|")}`, "g");
169
+ }
170
+ formattingTokensRegexFromDefinitions();
171
+ /**
172
+ * Add formatting tokens to list of global formatting tokens.
173
+ * @param newTokens - list of new parsing token definitions
174
+ */
175
+ function addFormatTokenDefinitions(newTokens) {
176
+ for (const key in newTokens) if (!Object.prototype.hasOwnProperty.call(formatTokensDefinitions, key)) formatTokensDefinitions[key] = newTokens[key];
177
+ formattingTokensRegexFromDefinitions();
178
+ }
179
+ function formatImpl(that, formatStr) {
180
+ if (!that.isValid()) return constants_default.INVALID_DATE_STRING;
181
+ const activeFormatString = formatStr || constants_default.FORMAT_DEFAULT;
182
+ const matches = (match) => {
183
+ const formatter = formatTokensDefinitions[match];
184
+ return formatter(that, formatStr);
185
+ };
186
+ return activeFormatString.replace(formattingTokensRegex, (match, $1) => $1 || matches(match));
145
187
  }
146
188
 
147
- // src/core/parseDate.ts
189
+ //#endregion
190
+ //#region src/core/Impl/parse.ts
191
+ /**
192
+ * Create a Date object from an array of date components (year, month, ...).
193
+ * The month is 0 based (0..11).
194
+ * @param this - context to access the right function 'dateFromDateComponents'
195
+ * @param dateArray - array with date components (y, M, D, h, m, s ms)
196
+ * @returns Date object created from given array elements
197
+ */
148
198
  function parseArrayToDate(dateArray) {
149
- const dateArrayTuple = [0, 0, 1, 0, 0, 0, 0];
150
- dateArray.forEach((value, index) => {
151
- if (value !== void 0) {
152
- dateArrayTuple[index] = value;
153
- }
154
- });
155
- return new Date(...dateArrayTuple);
199
+ const dateArrayTuple = [
200
+ 0,
201
+ 1,
202
+ 1,
203
+ 0,
204
+ 0,
205
+ 0,
206
+ 0
207
+ ];
208
+ dateArray.forEach((value, index) => {
209
+ if (value !== void 0) dateArrayTuple[index] = index !== 1 ? value : value + 1;
210
+ });
211
+ return this.dateFromDateComponents(...dateArrayTuple);
156
212
  }
157
- function parseDate(date, utc = false) {
158
- if (date instanceof Date)
159
- return new Date(date);
160
- if (date === null)
161
- return new Date(Number.NaN);
162
- if (isUndefined(date))
163
- return /* @__PURE__ */ new Date();
164
- if (isEmptyObject(date))
165
- return /* @__PURE__ */ new Date();
166
- if (Array.isArray(date))
167
- return parseArrayToDate(date);
168
- if (typeof date === "string" && !/Z$/i.test(date)) {
169
- const d = date.match(constant_exports.REGEX_PARSE);
170
- if (d) {
171
- const Y = Number(d[1]);
172
- const M = Number(d[2]) - 1 || 0;
173
- const D = Number(d[3] || 1);
174
- const h = Number(d[4] || 0);
175
- const m = Number(d[5] || 0);
176
- const s = Number(d[6] || 0);
177
- const ms = Number((d[7] || "0").substring(0, 3));
178
- if (utc) {
179
- return new Date(Date.UTC(Y, M, D, h, m, s, ms));
180
- }
181
- return new Date(Y, M, D, h, m, s, ms);
182
- }
183
- }
184
- return new Date(date);
213
+
214
+ //#endregion
215
+ //#region src/core/Impl/startOf.ts
216
+ function startOfImpl(that, unit, reverse = false) {
217
+ const result = that.clone();
218
+ const setterFunc = result["$set"];
219
+ const instanceFactorySet = (method, slice) => {
220
+ const argumentStart = [
221
+ 0,
222
+ 0,
223
+ 0,
224
+ 0
225
+ ];
226
+ const argumentEnd = [
227
+ 23,
228
+ 59,
229
+ 59,
230
+ 999
231
+ ];
232
+ const argument = reverse ? argumentEnd.slice(slice) : argumentStart.slice(slice);
233
+ setterFunc.call(result, method, argument);
234
+ };
235
+ const instanceFactory = (date, month) => {
236
+ setterFunc.call(result, constants_default.MONTH, [month, date]);
237
+ };
238
+ const $month = result.month();
239
+ switch (normalizeUnit(unit)) {
240
+ case constants_default.YEAR:
241
+ reverse ? instanceFactory(31, 11) : instanceFactory(1, 0);
242
+ instanceFactorySet(constants_default.HOUR, 0);
243
+ break;
244
+ case constants_default.MONTH:
245
+ reverse ? instanceFactory(0, $month + 1) : instanceFactory(1, $month);
246
+ instanceFactorySet(constants_default.HOUR, 0);
247
+ break;
248
+ case constants_default.DAY:
249
+ case constants_default.DAY_OF_MONTH:
250
+ instanceFactorySet(constants_default.HOUR, 0);
251
+ break;
252
+ case constants_default.HOUR:
253
+ instanceFactorySet(constants_default.MIN, 1);
254
+ break;
255
+ case constants_default.MIN:
256
+ instanceFactorySet(constants_default.SECOND, 2);
257
+ break;
258
+ case constants_default.SECOND:
259
+ instanceFactorySet(constants_default.MS, 3);
260
+ break;
261
+ default: break;
262
+ }
263
+ return result;
185
264
  }
186
265
 
187
- // src/core/EsDay.ts
188
- var EsDay = class _EsDay {
189
- $d;
190
- /**
191
- * mainly for plugin compatibility
192
- * store data such as locale name, utc mode, etc.
193
- */
194
- $conf = {};
195
- constructor(d, conf) {
196
- this.$conf = { ...conf };
197
- this.parse(d);
198
- }
199
- parse(d) {
200
- this.$d = this.$parseDate(d);
201
- }
202
- $parseDate(d, utc = false) {
203
- return parseDate(d, utc);
204
- }
205
- isSame(that, units = constant_exports.MS) {
206
- const other = esday(that);
207
- return this.startOf(units) <= other && other <= this.endOf(units);
208
- }
209
- isAfter(that, units = constant_exports.MS) {
210
- return esday(that) < this.startOf(units);
211
- }
212
- isBefore(that, units = constant_exports.MS) {
213
- return this.endOf(units) < esday(that);
214
- }
215
- // return this milliseconds
216
- valueOf() {
217
- return this.$d.getTime();
218
- }
219
- unix() {
220
- return Math.floor(this.valueOf() / 1e3);
221
- }
222
- isValid() {
223
- return !(this.$d.toString() === constant_exports.INVALID_DATE_STRING);
224
- }
225
- clone() {
226
- const newInst = new _EsDay(this.toDate());
227
- newInst.$conf = { ...this.$conf };
228
- return newInst;
229
- }
230
- format(formatStr) {
231
- return formatImpl(this, formatStr);
232
- }
233
- utcOffset() {
234
- return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
235
- }
236
- startOf(units) {
237
- return startOfImpl(this, units);
238
- }
239
- endOf(units) {
240
- return startOfImpl(this, units, true);
241
- }
242
- add(number, units) {
243
- return addImpl(this, number, units);
244
- }
245
- subtract(number, units) {
246
- return this.add(-number, units);
247
- }
248
- get(units) {
249
- return getUnitInDate(this.$d, units);
250
- }
251
- set(unit, ...values) {
252
- return this.clone().$set(unit, values);
253
- }
254
- toDate() {
255
- return new Date(this.valueOf());
256
- }
257
- toJSON() {
258
- return this.isValid() ? this.toISOString() : null;
259
- }
260
- toISOString() {
261
- return this.$d.toISOString();
262
- }
263
- toString() {
264
- return this.$d.toUTCString();
265
- }
266
- $set(unit, values, utc = false) {
267
- if (prettyUnit(unit) === constant_exports.DAY) {
268
- setUnitInDate(this.$d, constant_exports.DATE, this.date() + (values[0] - this.day()), utc);
269
- } else {
270
- setUnitInDate(this.$d, unit, values, utc);
271
- }
272
- return this;
273
- }
266
+ //#endregion
267
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js
268
+ var require_checkPrivateRedeclaration = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js": ((exports, module) => {
269
+ function _checkPrivateRedeclaration(e, t) {
270
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
271
+ }
272
+ module.exports = _checkPrivateRedeclaration, module.exports.__esModule = true, module.exports["default"] = module.exports;
273
+ }) });
274
+
275
+ //#endregion
276
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js
277
+ var require_classPrivateMethodInitSpec = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js": ((exports, module) => {
278
+ var checkPrivateRedeclaration = require_checkPrivateRedeclaration();
279
+ function _classPrivateMethodInitSpec$1(e, a) {
280
+ checkPrivateRedeclaration(e, a), a.add(e);
281
+ }
282
+ module.exports = _classPrivateMethodInitSpec$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
283
+ }) });
284
+
285
+ //#endregion
286
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/typeof.js
287
+ var require_typeof = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/typeof.js": ((exports, module) => {
288
+ function _typeof$2(o) {
289
+ "@babel/helpers - typeof";
290
+ return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
291
+ return typeof o$1;
292
+ } : function(o$1) {
293
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
294
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
295
+ }
296
+ module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
297
+ }) });
298
+
299
+ //#endregion
300
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
301
+ var require_toPrimitive = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js": ((exports, module) => {
302
+ var _typeof$1 = require_typeof()["default"];
303
+ function toPrimitive$1(t, r) {
304
+ if ("object" != _typeof$1(t) || !t) return t;
305
+ var e = t[Symbol.toPrimitive];
306
+ if (void 0 !== e) {
307
+ var i = e.call(t, r || "default");
308
+ if ("object" != _typeof$1(i)) return i;
309
+ throw new TypeError("@@toPrimitive must return a primitive value.");
310
+ }
311
+ return ("string" === r ? String : Number)(t);
312
+ }
313
+ module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
314
+ }) });
315
+
316
+ //#endregion
317
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
318
+ var require_toPropertyKey = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js": ((exports, module) => {
319
+ var _typeof = require_typeof()["default"];
320
+ var toPrimitive = require_toPrimitive();
321
+ function toPropertyKey$1(t) {
322
+ var i = toPrimitive(t, "string");
323
+ return "symbol" == _typeof(i) ? i : i + "";
324
+ }
325
+ module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
326
+ }) });
327
+
328
+ //#endregion
329
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
330
+ var require_defineProperty = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js": ((exports, module) => {
331
+ var toPropertyKey = require_toPropertyKey();
332
+ function _defineProperty$1(e, r, t) {
333
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
334
+ value: t,
335
+ enumerable: !0,
336
+ configurable: !0,
337
+ writable: !0
338
+ }) : e[r] = t, e;
339
+ }
340
+ module.exports = _defineProperty$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
341
+ }) });
342
+
343
+ //#endregion
344
+ //#region node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js
345
+ var require_assertClassBrand = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js": ((exports, module) => {
346
+ function _assertClassBrand$1(e, t, n) {
347
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
348
+ throw new TypeError("Private element is not present on this object");
349
+ }
350
+ module.exports = _assertClassBrand$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
351
+ }) });
352
+
353
+ //#endregion
354
+ //#region src/core/EsDay.ts
355
+ var import_classPrivateMethodInitSpec = /* @__PURE__ */ __toESM(require_classPrivateMethodInitSpec(), 1);
356
+ var import_defineProperty = /* @__PURE__ */ __toESM(require_defineProperty(), 1);
357
+ var import_assertClassBrand = /* @__PURE__ */ __toESM(require_assertClassBrand(), 1);
358
+ var _EsDay_brand = /* @__PURE__ */ new WeakSet();
359
+ var EsDay = class EsDay {
360
+ constructor(d, conf) {
361
+ (0, import_classPrivateMethodInitSpec.default)(this, _EsDay_brand);
362
+ (0, import_defineProperty.default)(this, "$d", void 0);
363
+ (0, import_defineProperty.default)(this, "$conf", {});
364
+ if (!isUndefined(conf)) this.$conf = structuredClone(conf);
365
+ this.$parse(d);
366
+ }
367
+ $parse(d) {
368
+ this.$d = (0, import_assertClassBrand.default)(_EsDay_brand, this, _parseImpl).call(this, d);
369
+ }
370
+ /**
371
+ * Create a Date object from the date components (year, month, ...).
372
+ * The month is 1 based (1..12).
373
+ * Potential hook for plugins to change the details of Date creation.
374
+ * @param Y - year of date to create
375
+ * @param M - year of date to create (1..12)
376
+ * @param D - year of date to create
377
+ * @param h - year of date to create
378
+ * @param m - year of date to create
379
+ * @param s - year of date to create
380
+ * @param ms - year of date to create
381
+ * @param offsetMs - offset from utc in milliseconds
382
+ * @returns Date object created from input parameters
383
+ */
384
+ dateFromDateComponents(Y, M, D, h, m, s, ms, offsetMs) {
385
+ const parsedYearOrDefault = Y ?? (/* @__PURE__ */ new Date()).getFullYear();
386
+ const parsedMonthOrDefault = M ?? (Y !== void 0 ? 1 : (/* @__PURE__ */ new Date()).getMonth() + 1);
387
+ const dateComponents = {
388
+ Y: parsedYearOrDefault,
389
+ M: parsedMonthOrDefault - 1,
390
+ D: D ?? 1,
391
+ h: h ?? 0,
392
+ m: m ?? 0,
393
+ s: s ?? 0,
394
+ ms: ms ?? 0
395
+ };
396
+ const yearWithoutCentury = Math.abs(parsedYearOrDefault) < 100;
397
+ let overflowed = false;
398
+ let result = new Date(dateComponents.Y, dateComponents.M, dateComponents.D, dateComponents.h, dateComponents.m, dateComponents.s, dateComponents.ms);
399
+ if (yearWithoutCentury) result.setFullYear(dateComponents.Y);
400
+ overflowed = M !== void 0 && M - 1 !== result.getMonth() || D !== void 0 && D !== result.getDate() || h !== void 0 && h !== result.getHours() || m !== void 0 && m !== result.getMinutes() || s !== void 0 && s !== result.getSeconds();
401
+ if (overflowed) result = constants_default.INVALID_DATE;
402
+ else if (!isUndefined(offsetMs)) {
403
+ const currentOffsetMin = result.getTimezoneOffset();
404
+ const newMs = result.getMilliseconds() - (currentOffsetMin * 6e4 + offsetMs);
405
+ result.setMilliseconds(newMs);
406
+ }
407
+ return result;
408
+ }
409
+ isSame(that, units = constants_default.MS) {
410
+ const other = esday(that);
411
+ return this.startOf(units) <= other && other <= this.endOf(units);
412
+ }
413
+ isAfter(that, units = constants_default.MS) {
414
+ return esday(that) < this.startOf(units);
415
+ }
416
+ isBefore(that, units = constants_default.MS) {
417
+ return this.endOf(units) < esday(that);
418
+ }
419
+ valueOf() {
420
+ return this.$d.getTime();
421
+ }
422
+ unix() {
423
+ return Math.floor(this.valueOf() / 1e3);
424
+ }
425
+ isValid() {
426
+ return isValidDate(this.$d);
427
+ }
428
+ clone() {
429
+ const newInst = new EsDay(this.$d);
430
+ newInst.$conf = structuredClone(this.$conf);
431
+ return newInst;
432
+ }
433
+ format(formatStr) {
434
+ return formatImpl(this, formatStr);
435
+ }
436
+ startOf(units) {
437
+ return startOfImpl(this, units);
438
+ }
439
+ endOf(units) {
440
+ return startOfImpl(this, units, true);
441
+ }
442
+ add(value, unit) {
443
+ if (!isObject(value) && unit !== void 0) return addImpl(this, value, unit);
444
+ return this.clone();
445
+ }
446
+ subtract(value, unit) {
447
+ if (!isObject(value) && unit !== void 0) return this.add(-value, unit);
448
+ return this.clone();
449
+ }
450
+ diff(date, units, asFloat = false) {
451
+ return diffImpl(this, date, units, asFloat);
452
+ }
453
+ utcOffset(offset, _keepLocalTime) {
454
+ if (offset !== void 0) return new EsDay(constants_default.INVALID_DATE);
455
+ return -Math.round(this["$d"].getTimezoneOffset());
456
+ }
457
+ get(unit) {
458
+ const normalizedUnit = normalizeUnitWithPlurals(unit);
459
+ if (normalizedUnit === constants_default.QUARTER || normalizedUnit === constants_default.WEEK) return NaN;
460
+ return getUnitInDate(this.$d, unit);
461
+ }
462
+ set(unit, ...values) {
463
+ return this.clone().$set(unit, values);
464
+ }
465
+ toDate() {
466
+ return new Date(this.valueOf());
467
+ }
468
+ toJSON() {
469
+ return this.isValid() ? this.toISOString() : null;
470
+ }
471
+ toISOString() {
472
+ if (this.isValid()) return this.$d.toISOString();
473
+ return constants_default.INVALID_DATE_STRING;
474
+ }
475
+ toString() {
476
+ return this.$d.toUTCString();
477
+ }
478
+ $set(unit, values) {
479
+ if (isObject(unit)) return this.clone();
480
+ const normalizedUnit = normalizeUnitWithPlurals(unit);
481
+ if (normalizedUnit === constants_default.DAY) setUnitInDate(this.$d, constants_default.DAY_OF_MONTH, this.date() + (values[0] - this.day()));
482
+ else if (normalizedUnit === constants_default.MONTH) {
483
+ const originalDate = values.length === 1 ? this.date() : values[1];
484
+ setUnitInDate(this.$d, constants_default.MONTH, values);
485
+ if (originalDate > 0 && this.date() !== originalDate) setUnitInDate(this.$d, constants_default.DAY_OF_MONTH, 0);
486
+ } else if (normalizedUnit !== constants_default.QUARTER && normalizedUnit !== constants_default.WEEK) {
487
+ const typedUnit = normalizedUnit;
488
+ setUnitInDate(this.$d, typedUnit, values);
489
+ }
490
+ return this;
491
+ }
492
+ };
493
+ /**
494
+ * Convert a parsed element to a number | undefined;
495
+ * empty strings are treated as undefined.
496
+ * @param parsedElement - element to be converted
497
+ * @returns parsed element as number
498
+ */
499
+ function _toNumber(parsedElement) {
500
+ if (parsedElement === void 0 || typeof parsedElement === "string" && parsedElement.trim().length === 0) return;
501
+ return Number(parsedElement);
502
+ }
503
+ /**
504
+ * Convert a parsed milliseconds element to a number | undefined;
505
+ * for milliseconds only the 1st 3 digits are considered;
506
+ * empty strings are treated as '0'.
507
+ * @param parsedElement - element to be converted
508
+ * @returns parsed element as number
509
+ */
510
+ function _toMsNumber(parsedElement) {
511
+ if (parsedElement === void 0) return;
512
+ return Number(parsedElement.toString().slice(0, 3));
513
+ }
514
+ function _parseImpl(date) {
515
+ if (date instanceof Date) return new Date(date);
516
+ if (date === null) return /* @__PURE__ */ new Date(NaN);
517
+ if (isUndefined(date)) return /* @__PURE__ */ new Date();
518
+ if (isEmptyObject(date)) return /* @__PURE__ */ new Date();
519
+ if (Array.isArray(date)) return parseArrayToDate.call(this, date);
520
+ if (typeof date === "string" && !/Z$/i.test(date)) {
521
+ const d = date.match(constants_default.REGEX_PARSE_DEFAULT);
522
+ if (d) {
523
+ const Y = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[1]);
524
+ const M = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[2]);
525
+ const D = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[3]);
526
+ const h = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[4]);
527
+ const m = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[5]);
528
+ const s = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toNumber).call(this, d[6]);
529
+ const ms = (0, import_assertClassBrand.default)(_EsDay_brand, this, _toMsNumber).call(this, d[7]);
530
+ return this.dateFromDateComponents(Y, M, D, h, m, s, ms);
531
+ }
532
+ }
533
+ return new Date(date);
534
+ }
535
+ /**
536
+ * Getter / Setter for date components:
537
+ * esday().year(...args)
538
+ * esday().month(...args)
539
+ * esday().date(...args)
540
+ * esday().day(...args)
541
+ * esday().hour(...args)
542
+ * esday().minute(...args)
543
+ * esday().second(...args)
544
+ * esday().millisecond(...args)
545
+ */
546
+ for (const key of prettyUnitsDate) EsDay.prototype[key] = function(...args) {
547
+ if (args?.length) return this.set(key, ...args);
548
+ return this.get(key);
274
549
  };
275
- var helperNames = ["year", "month", "date", "day", "hour", "minute", "second", "millisecond"];
276
- helperNames.forEach((key) => {
277
- EsDay.prototype[key] = function(...args) {
278
- if (args?.length) {
279
- return this.set(key, ...args);
280
- } else {
281
- return this.get(key);
282
- }
283
- };
284
- });
285
550
 
286
- // src/core/factory.ts
287
- var esday = (d, ...others) => {
288
- if (d instanceof EsDay) {
289
- return d.clone();
290
- } else {
291
- const conf = {};
292
- others.forEach((o, i) => {
293
- if (isObject(o)) {
294
- Object.assign(conf, o);
295
- } else {
296
- conf[`args_${i + 1}`] = o;
297
- }
298
- });
299
- return new EsDay(d, conf);
300
- }
551
+ //#endregion
552
+ //#region src/core/factory.ts
553
+ const esday = (d, ...others) => {
554
+ if (d instanceof EsDay) return d.clone();
555
+ const conf = {};
556
+ others.forEach((o, i) => {
557
+ if (isArray(o)) conf[`args_${i + 1}`] = o;
558
+ else if (isObject(o)) Object.assign(conf, o);
559
+ else conf[`args_${i + 1}`] = o;
560
+ });
561
+ return new EsDay(d, conf);
301
562
  };
563
+ esday.addFormatTokenDefinitions = addFormatTokenDefinitions;
302
564
  esday.extend = (plugin, option) => {
303
- if (!plugin.$i) {
304
- plugin(option, EsDay, esday);
305
- plugin.$i = true;
306
- }
307
- return esday;
565
+ if (!plugin.$i) {
566
+ plugin(option || {}, EsDay, esday);
567
+ plugin.$i = true;
568
+ }
569
+ return esday;
308
570
  };
309
571
 
310
- export { EsDay, esday };
572
+ //#endregion
573
+ export { EsDay, esday };