esday 0.3.0 → 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 (378) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +51 -0
  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 +552 -326
  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 +8 -0
  112. package/locales/en.js +3 -0
  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 +15 -0
  324. package/locales/zh.js +3 -0
  325. package/package.json +79 -21
  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 -0
  351. package/plugins/locale/index.js +7 -0
  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 +19 -0
  373. package/plugins/utc/index.js +194 -0
  374. package/plugins/week/index.d.ts +21 -0
  375. package/plugins/week/index.js +360 -0
  376. package/EsDay-CKy0jEj2.d.ts +0 -68
  377. package/plugins/customParseFormat/index.d.ts +0 -5
  378. package/plugins/customParseFormat/index.js +0 -159
package/index.js CHANGED
@@ -1,347 +1,573 @@
1
- import { isArray } from 'radash';
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/constant.ts
4
- var MS = "millisecond";
5
- var S = "second";
6
- var MIN = "minute";
7
- var H = "hour";
8
- var D = "day";
9
- var W = "week";
10
- var M = "month";
11
- var Q = "quarter";
12
- var Y = "year";
13
- var DATE = "date";
14
- var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
15
- var INVALID_DATE_STRING = "Invalid Date";
16
- var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
17
- var REGEX_FORMAT = /\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
18
- function prettyUnit(u) {
19
- const special = {
20
- M,
21
- y: Y,
22
- w: W,
23
- d: D,
24
- D: DATE,
25
- h: H,
26
- m: MIN,
27
- s: S,
28
- ms: MS,
29
- Q
30
- };
31
- return special[u] || String(u || "").toLowerCase().replace(/s$/, "");
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
+ }
32
63
  }
33
- function isUndefined(value) {
34
- return value === void 0;
64
+
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);
35
82
  }
36
- function callDateGetOrSet(date, field, utc, value) {
37
- if (!isUndefined(value) && field !== "Day") {
38
- date[`set${utc ? "UTC" : ""}${field}`](...isArray(value) ? value : [value]);
39
- return;
40
- }
41
- return date[`get${utc ? "UTC" : ""}${field}`]();
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);
42
90
  }
43
- function getAllFieldsInDate(date, utc) {
44
- return {
45
- year: callDateGetOrSet(date, "FullYear", utc),
46
- month: callDateGetOrSet(date, "Month", utc),
47
- date: callDateGetOrSet(date, "Date", utc),
48
- day: callDateGetOrSet(date, "Day", utc),
49
- hour: callDateGetOrSet(date, "Hours", utc),
50
- minute: callDateGetOrSet(date, "Minutes", utc),
51
- second: callDateGetOrSet(date, "Seconds", utc),
52
- millisecond: callDateGetOrSet(date, "Milliseconds", utc)
53
- };
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);
54
130
  }
55
- function padStart(str, length, pad) {
56
- str = String(str);
57
- if (!str || str.length >= length)
58
- return str;
59
- return `${Array.from({ length: length + 1 - str.length }).join(pad)}${str}`;
131
+
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;
60
165
  }
61
- function wrapperInst(date, instance) {
62
- const newInst = instance.clone();
63
- newInst["$d"] = new Date(date);
64
- return newInst;
166
+ function formattingTokensRegexFromDefinitions() {
167
+ const tokenKeys = Object.keys(formatTokensDefinitions).sort(compareTokens);
168
+ formattingTokensRegex = new RegExp(`${formattingSeparatorsRegex}|${tokenKeys.join("|")}`, "g");
65
169
  }
66
-
67
- // src/core/Impl/add.ts
68
- function addImpl(that, number, units) {
69
- const $d = that["$d"];
70
- const unit = prettyUnit(units);
71
- const instanceFactorySet = (multiplier) => {
72
- const newInstance = that.clone();
73
- newInstance["$d"].setDate($d.getDate() + Math.round(multiplier * number));
74
- return newInstance;
75
- };
76
- if (unit === M) {
77
- return that.set("month", that.get("month") + number);
78
- }
79
- if (unit === Y) {
80
- return that.set("year", that.get("year") + number);
81
- }
82
- if (unit === DATE || unit === D) {
83
- return instanceFactorySet(1);
84
- }
85
- if (unit === W) {
86
- return instanceFactorySet(7);
87
- }
88
- const step = {
89
- minute: 60 * 1e3,
90
- hour: 60 * 60 * 1e3,
91
- second: 1e3
92
- }[unit] || 1;
93
- const nextTimeStamp = $d.getTime() + number * step;
94
- return wrapperInst(new Date(nextTimeStamp), that);
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();
95
178
  }
96
-
97
- // src/core/Impl/format.ts
98
179
  function formatImpl(that, formatStr) {
99
- if (!that.isValid())
100
- return INVALID_DATE_STRING;
101
- const $d = that["$d"];
102
- const dates = getAllFieldsInDate($d, that["$u"]);
103
- const str = formatStr || FORMAT_DEFAULT;
104
- const get$H = (num) => padStart(dates.hour % 12 || 12, num, "0");
105
- const meridiemFunc = (hour, _minute, isLowercase) => {
106
- const m = hour < 12 ? "AM" : "PM";
107
- return isLowercase ? m.toLowerCase() : m;
108
- };
109
- const matches = (match) => {
110
- switch (match) {
111
- case "YY":
112
- return String(dates.year).slice(-2);
113
- case "YYYY":
114
- return padStart(dates.year, 4, "0");
115
- case "M":
116
- return dates.month + 1;
117
- case "MM":
118
- return padStart(dates.month + 1, 2, "0");
119
- case "D":
120
- return dates.date;
121
- case "DD":
122
- return padStart(dates.date, 2, "0");
123
- case "d":
124
- return String(dates.day);
125
- case "H":
126
- return String(dates.hour);
127
- case "HH":
128
- return padStart(dates.hour, 2, "0");
129
- case "h":
130
- return get$H(1);
131
- case "hh":
132
- return get$H(2);
133
- case "a":
134
- return meridiemFunc(dates.hour, dates.minute, true);
135
- case "A":
136
- return meridiemFunc(dates.hour, dates.minute, false);
137
- case "m":
138
- return String(dates.minute);
139
- case "mm":
140
- return padStart(dates.minute, 2, "0");
141
- case "s":
142
- return String(dates.second);
143
- case "ss":
144
- return padStart(dates.second, 2, "0");
145
- case "SSS":
146
- return padStart(dates.millisecond, 3, "0");
147
- }
148
- return null;
149
- };
150
- return str.replace(REGEX_FORMAT, (match, $1) => $1 || matches(match));
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));
151
187
  }
152
188
 
153
- // src/core/Impl/startOf.ts
154
- function startOfImpl(that, unit, reverse = false) {
155
- const result = that.toDate();
156
- const utc = that["$u"];
157
- const instanceFactorySet = (method, slice) => {
158
- const argumentStart = [0, 0, 0, 0];
159
- const argumentEnd = [23, 59, 59, 999];
160
- const argument = reverse ? argumentEnd.slice(slice) : argumentStart.slice(slice);
161
- callDateGetOrSet(result, method, utc, argument);
162
- };
163
- const instanceFactory = (d, m) => {
164
- callDateGetOrSet(result, "Month", utc, [m, d]);
165
- };
166
- const $M = callDateGetOrSet(result, "Month", utc);
167
- switch (prettyUnit(unit)) {
168
- case Y:
169
- reverse ? instanceFactory(31, 11) : instanceFactory(1, 0);
170
- instanceFactorySet("Hours", 0);
171
- break;
172
- case M:
173
- reverse ? instanceFactory(0, $M + 1) : instanceFactory(1, $M);
174
- instanceFactorySet("Hours", 0);
175
- break;
176
- case W: {
177
- const dayOfWeek = callDateGetOrSet(result, "Day", utc);
178
- const diff = (dayOfWeek < 1 ? 7 : 0) + dayOfWeek - (reverse ? 6 : 0);
179
- callDateGetOrSet(result, "Date", utc, callDateGetOrSet(result, "Date", utc) - diff);
180
- instanceFactorySet("Hours", 0);
181
- break;
182
- }
183
- case D:
184
- case DATE:
185
- instanceFactorySet("Hours", 0);
186
- break;
187
- case H:
188
- instanceFactorySet("Minutes", 1);
189
- break;
190
- case MIN:
191
- instanceFactorySet("Seconds", 2);
192
- break;
193
- case S:
194
- instanceFactorySet("Milliseconds", 3);
195
- break;
196
- }
197
- return wrapperInst(result, that);
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
+ */
198
+ function parseArrayToDate(dateArray) {
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);
198
212
  }
199
213
 
200
- // src/core/parseDate.ts
201
- function parseDate(date, utc = false) {
202
- if (isUndefined(date))
203
- return /* @__PURE__ */ new Date();
204
- if (date instanceof Date)
205
- return new Date(date);
206
- if (typeof date === "string" && !/Z$/i.test(date)) {
207
- const d = date.match(REGEX_PARSE);
208
- if (d) {
209
- const Y2 = Number(d[1]);
210
- const M2 = Number(d[2]) - 1 || 0;
211
- const D2 = Number(d[3] || 1);
212
- const h = Number(d[4] || 0);
213
- const m = Number(d[5] || 0);
214
- const s = Number(d[6] || 0);
215
- const ms = Number((d[7] || "0").substring(0, 3));
216
- if (utc) {
217
- return new Date(Date.UTC(Y2, M2, D2, h, m, s, ms));
218
- }
219
- return new Date(Y2, M2, D2, h, m, s, ms);
220
- }
221
- }
222
- return new Date(date);
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;
223
264
  }
224
265
 
225
- // src/core/EsDay.ts
226
- var EsDay = class _EsDay {
227
- $d;
228
- // utc mode
229
- $u = false;
230
- constructor(d, utc, ...others) {
231
- this.parse(d, utc, ...others);
232
- }
233
- parse(d, utc, ..._others) {
234
- this.$d = parseDate(d);
235
- this.$u = utc;
236
- }
237
- // return utc instance
238
- utc() {
239
- return new _EsDay(this.toDate(), true);
240
- }
241
- isSame(that, units) {
242
- const other = esday(that);
243
- return this.startOf(units) <= other && other <= this.endOf(units);
244
- }
245
- isAfter(that, units) {
246
- return esday(that) < this.startOf(units);
247
- }
248
- isBefore(that, units) {
249
- return this.endOf(units) < esday(that);
250
- }
251
- // return this milliseconds
252
- valueOf() {
253
- return this.$d.getTime();
254
- }
255
- unix() {
256
- return Math.floor(this.valueOf() / 1e3);
257
- }
258
- isValid() {
259
- return !(this.$d.toString() === INVALID_DATE_STRING);
260
- }
261
- clone() {
262
- return new _EsDay(this.toDate(), this.$u);
263
- }
264
- format(formatStr) {
265
- return formatImpl(this, formatStr);
266
- }
267
- startOf(units) {
268
- return startOfImpl(this, units);
269
- }
270
- endOf(units) {
271
- return startOfImpl(this, units, true);
272
- }
273
- add(number, units) {
274
- return addImpl(this, number, units);
275
- }
276
- subtract(number, units) {
277
- return this.add(-number, units);
278
- }
279
- get(units) {
280
- return getAllFieldsInDate(this.$d, this.$u)[prettyUnit(units)];
281
- }
282
- set(units, value) {
283
- return this.clone().$set(units, value);
284
- }
285
- toDate() {
286
- return new Date(this.valueOf());
287
- }
288
- toJSON() {
289
- return this.isValid() ? this.toISOString() : null;
290
- }
291
- toISOString() {
292
- return this.$d.toISOString();
293
- }
294
- toString() {
295
- return this.$d.toUTCString();
296
- }
297
- $set(units, value) {
298
- const unit = prettyUnit(units);
299
- const name = {
300
- [D]: `Date`,
301
- [DATE]: `Date`,
302
- [M]: `Month`,
303
- [Y]: `FullYear`,
304
- [H]: `Hours`,
305
- [MIN]: `Minutes`,
306
- [S]: `Seconds`,
307
- [MS]: `Milliseconds`
308
- }[unit];
309
- const arg = unit === D ? this.get("date") + (value - this.get("day")) : value;
310
- callDateGetOrSet(this.$d, name, this.$u, arg);
311
- return this;
312
- }
313
- };
314
- ["year", "month", "date", "day", "hour", "minute", "second", "millisecond"].forEach((key) => {
315
- EsDay.prototype[key] = function(value) {
316
- if (value !== void 0) {
317
- return this.set(key, value);
318
- } else {
319
- return this.get(key);
320
- }
321
- };
322
- });
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
+ }) });
323
274
 
324
- // src/core/factory.ts
325
- var esday = (d, ...others) => {
326
- if (d instanceof EsDay) {
327
- return d.clone();
328
- } else {
329
- return new EsDay(d, false, ...others);
330
- }
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
+ }
331
492
  };
332
- esday.utc = (d, ...others) => {
333
- if (d instanceof EsDay) {
334
- return d.clone().utc();
335
- } else {
336
- return new EsDay(d, true, ...others);
337
- }
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);
549
+ };
550
+
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);
338
562
  };
563
+ esday.addFormatTokenDefinitions = addFormatTokenDefinitions;
339
564
  esday.extend = (plugin, option) => {
340
- if (!plugin.$i) {
341
- plugin(option, EsDay, esday);
342
- plugin.$i = true;
343
- }
344
- return esday;
565
+ if (!plugin.$i) {
566
+ plugin(option || {}, EsDay, esday);
567
+ plugin.$i = true;
568
+ }
569
+ return esday;
345
570
  };
346
571
 
347
- export { EsDay, esday };
572
+ //#endregion
573
+ export { EsDay, esday };