esday 0.4.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +21 -0
  3. package/README.md +63 -33
  4. package/chunks/AyQQ6US-.js +84 -0
  5. package/chunks/BkjWOpMU.js +68 -0
  6. package/chunks/C5qDMHT5.d.ts +6 -0
  7. package/chunks/CODi8AFH.d.ts +231 -0
  8. package/chunks/CXWzCl3n.js +481 -0
  9. package/chunks/CdvTtmWL.js +56 -0
  10. package/chunks/Shk32pTP.js +9 -0
  11. package/chunks/v_QBn7Xm.js +25 -0
  12. package/chunks/xt8C2lbv.js +38 -0
  13. package/index.d.mts +3 -0
  14. package/index.mjs +3 -0
  15. package/locales/af.d.mts +6 -0
  16. package/locales/af.mjs +108 -0
  17. package/locales/am.d.mts +6 -0
  18. package/locales/am.mjs +108 -0
  19. package/locales/ar-dz.d.mts +9 -0
  20. package/locales/ar-dz.mjs +30 -0
  21. package/locales/ar-iq.d.mts +9 -0
  22. package/locales/ar-iq.mjs +12 -0
  23. package/locales/ar-kw.d.mts +9 -0
  24. package/locales/ar-kw.mjs +26 -0
  25. package/locales/ar-ly.d.mts +9 -0
  26. package/locales/ar-ly.mjs +12 -0
  27. package/locales/ar-ma.d.mts +9 -0
  28. package/locales/ar-ma.mjs +27 -0
  29. package/locales/ar-sa.d.mts +9 -0
  30. package/locales/ar-sa.mjs +27 -0
  31. package/locales/ar-tn.d.mts +9 -0
  32. package/locales/ar-tn.mjs +27 -0
  33. package/locales/ar.d.mts +6 -0
  34. package/locales/ar.mjs +198 -0
  35. package/locales/az.d.mts +6 -0
  36. package/locales/az.mjs +108 -0
  37. package/locales/be.d.mts +6 -0
  38. package/locales/be.mjs +136 -0
  39. package/locales/bg.d.mts +6 -0
  40. package/locales/bg.mjs +127 -0
  41. package/locales/bi.d.mts +6 -0
  42. package/locales/bi.mjs +108 -0
  43. package/locales/bm.d.mts +6 -0
  44. package/locales/bm.mjs +108 -0
  45. package/locales/bn-bd.d.mts +9 -0
  46. package/locales/bn-bd.mjs +22 -0
  47. package/locales/bn.d.mts +6 -0
  48. package/locales/bn.mjs +137 -0
  49. package/locales/bo.d.mts +6 -0
  50. package/locales/bo.mjs +108 -0
  51. package/locales/br.d.mts +6 -0
  52. package/locales/br.mjs +180 -0
  53. package/locales/bs.d.mts +6 -0
  54. package/locales/bs.mjs +130 -0
  55. package/locales/ca.d.mts +6 -0
  56. package/locales/ca.mjs +142 -0
  57. package/locales/cs.d.mts +6 -0
  58. package/locales/cs.mjs +186 -0
  59. package/locales/cv.d.mts +6 -0
  60. package/locales/cv.mjs +108 -0
  61. package/locales/cy.d.mts +6 -0
  62. package/locales/cy.mjs +108 -0
  63. package/locales/da.d.mts +6 -0
  64. package/locales/da.mjs +108 -0
  65. package/locales/de-at.d.mts +9 -0
  66. package/locales/de-at.mjs +42 -0
  67. package/locales/de-ch.d.mts +9 -0
  68. package/locales/de-ch.mjs +12 -0
  69. package/locales/de.d.mts +6 -0
  70. package/locales/de.mjs +131 -0
  71. package/locales/dv.d.mts +6 -0
  72. package/locales/dv.mjs +108 -0
  73. package/locales/el.d.mts +6 -0
  74. package/locales/el.mjs +117 -0
  75. package/locales/en-au.d.mts +9 -0
  76. package/locales/en-au.mjs +26 -0
  77. package/locales/en-ca.d.mts +9 -0
  78. package/locales/en-ca.mjs +26 -0
  79. package/locales/en-gb.d.mts +11 -0
  80. package/locales/en-gb.mjs +29 -0
  81. package/locales/en-ie.d.mts +9 -0
  82. package/locales/en-ie.mjs +25 -0
  83. package/locales/en-il.d.mts +9 -0
  84. package/locales/en-il.mjs +27 -0
  85. package/locales/en-in.d.mts +9 -0
  86. package/locales/en-in.mjs +25 -0
  87. package/locales/en-nz.d.mts +9 -0
  88. package/locales/en-nz.mjs +27 -0
  89. package/locales/en-sg.d.mts +9 -0
  90. package/locales/en-sg.mjs +27 -0
  91. package/locales/en-tt.d.mts +9 -0
  92. package/locales/en-tt.mjs +27 -0
  93. package/locales/en-us.d.mts +9 -0
  94. package/locales/en-us.mjs +12 -0
  95. package/locales/en.d.mts +6 -0
  96. package/locales/en.mjs +117 -0
  97. package/locales/eo.d.mts +6 -0
  98. package/locales/eo.mjs +108 -0
  99. package/locales/es-do.d.mts +9 -0
  100. package/locales/es-do.mjs +25 -0
  101. package/locales/es-mx.d.mts +9 -0
  102. package/locales/es-mx.mjs +13 -0
  103. package/locales/es-pr.d.mts +9 -0
  104. package/locales/es-pr.mjs +16 -0
  105. package/locales/es-us.d.mts +9 -0
  106. package/locales/es-us.mjs +12 -0
  107. package/locales/es.d.mts +6 -0
  108. package/locales/es.mjs +118 -0
  109. package/locales/et.d.mts +6 -0
  110. package/locales/et.mjs +146 -0
  111. package/locales/eu.d.mts +6 -0
  112. package/locales/eu.mjs +108 -0
  113. package/locales/fa.d.mts +6 -0
  114. package/locales/fa.mjs +108 -0
  115. package/locales/fi.d.mts +6 -0
  116. package/locales/fi.mjs +171 -0
  117. package/locales/fil.d.mts +6 -0
  118. package/locales/fil.mjs +108 -0
  119. package/locales/fo.d.mts +6 -0
  120. package/locales/fo.mjs +108 -0
  121. package/locales/fr-ca.d.mts +9 -0
  122. package/locales/fr-ca.mjs +16 -0
  123. package/locales/fr-ch.d.mts +9 -0
  124. package/locales/fr-ch.mjs +16 -0
  125. package/locales/fr.d.mts +6 -0
  126. package/locales/fr.mjs +110 -0
  127. package/locales/fy.d.mts +6 -0
  128. package/locales/fy.mjs +108 -0
  129. package/locales/ga.d.mts +6 -0
  130. package/locales/ga.mjs +108 -0
  131. package/locales/gd.d.mts +6 -0
  132. package/locales/gd.mjs +108 -0
  133. package/locales/gl.d.mts +6 -0
  134. package/locales/gl.mjs +118 -0
  135. package/locales/gom-deva.d.mts +6 -0
  136. package/locales/gom-deva.mjs +148 -0
  137. package/locales/gom-latn.d.mts +6 -0
  138. package/locales/gom-latn.mjs +148 -0
  139. package/locales/gu.d.mts +6 -0
  140. package/locales/gu.mjs +108 -0
  141. package/locales/he.d.mts +6 -0
  142. package/locales/he.mjs +132 -0
  143. package/locales/hi.d.mts +6 -0
  144. package/locales/hi.mjs +124 -0
  145. package/locales/hr.d.mts +6 -0
  146. package/locales/hr.mjs +195 -0
  147. package/locales/ht.d.mts +6 -0
  148. package/locales/ht.mjs +108 -0
  149. package/locales/hu.d.mts +6 -0
  150. package/locales/hu.mjs +144 -0
  151. package/locales/hy-am.d.mts +6 -0
  152. package/locales/hy-am.mjs +126 -0
  153. package/locales/id.d.mts +6 -0
  154. package/locales/id.mjs +108 -0
  155. package/locales/is.d.mts +6 -0
  156. package/locales/is.mjs +167 -0
  157. package/locales/it-ch.d.mts +9 -0
  158. package/locales/it-ch.mjs +27 -0
  159. package/locales/it.d.mts +6 -0
  160. package/locales/it.mjs +121 -0
  161. package/locales/ja.d.mts +12 -0
  162. package/locales/ja.mjs +111 -0
  163. package/locales/jv.d.mts +6 -0
  164. package/locales/jv.mjs +108 -0
  165. package/locales/ka.d.mts +6 -0
  166. package/locales/ka.mjs +125 -0
  167. package/locales/kk.d.mts +6 -0
  168. package/locales/kk.mjs +108 -0
  169. package/locales/km.d.mts +6 -0
  170. package/locales/km.mjs +108 -0
  171. package/locales/kn.d.mts +6 -0
  172. package/locales/kn.mjs +108 -0
  173. package/locales/ko.d.mts +6 -0
  174. package/locales/ko.mjs +107 -0
  175. package/locales/ku.d.mts +6 -0
  176. package/locales/ku.mjs +121 -0
  177. package/locales/ky.d.mts +6 -0
  178. package/locales/ky.mjs +108 -0
  179. package/locales/lb.d.mts +6 -0
  180. package/locales/lb.mjs +169 -0
  181. package/locales/lo.d.mts +6 -0
  182. package/locales/lo.mjs +107 -0
  183. package/locales/lt.d.mts +6 -0
  184. package/locales/lt.mjs +108 -0
  185. package/locales/lv.d.mts +6 -0
  186. package/locales/lv.mjs +108 -0
  187. package/locales/me.d.mts +6 -0
  188. package/locales/me.mjs +129 -0
  189. package/locales/mi.d.mts +6 -0
  190. package/locales/mi.mjs +108 -0
  191. package/locales/mk.d.mts +6 -0
  192. package/locales/mk.mjs +119 -0
  193. package/locales/ml.d.mts +6 -0
  194. package/locales/ml.mjs +111 -0
  195. package/locales/mn.d.mts +6 -0
  196. package/locales/mn.mjs +127 -0
  197. package/locales/mr.d.mts +6 -0
  198. package/locales/mr.mjs +229 -0
  199. package/locales/ms-my.d.mts +9 -0
  200. package/locales/ms-my.mjs +12 -0
  201. package/locales/ms.d.mts +6 -0
  202. package/locales/ms.mjs +108 -0
  203. package/locales/mt.d.mts +6 -0
  204. package/locales/mt.mjs +108 -0
  205. package/locales/my.d.mts +6 -0
  206. package/locales/my.mjs +134 -0
  207. package/locales/nb.d.mts +6 -0
  208. package/locales/nb.mjs +108 -0
  209. package/locales/ne.d.mts +6 -0
  210. package/locales/ne.mjs +108 -0
  211. package/locales/nl-be.d.mts +9 -0
  212. package/locales/nl-be.mjs +16 -0
  213. package/locales/nl.d.mts +6 -0
  214. package/locales/nl.mjs +108 -0
  215. package/locales/nn.d.mts +6 -0
  216. package/locales/nn.mjs +108 -0
  217. package/locales/oc-lnc.d.mts +6 -0
  218. package/locales/oc-lnc.mjs +125 -0
  219. package/locales/pa-in.d.mts +6 -0
  220. package/locales/pa-in.mjs +125 -0
  221. package/locales/pl.d.mts +6 -0
  222. package/locales/pl.mjs +162 -0
  223. package/locales/pt-br.d.mts +9 -0
  224. package/locales/pt-br.mjs +51 -0
  225. package/locales/pt.d.mts +6 -0
  226. package/locales/pt.mjs +110 -0
  227. package/locales/rn.d.mts +6 -0
  228. package/locales/rn.mjs +108 -0
  229. package/locales/ro.d.mts +6 -0
  230. package/locales/ro.mjs +108 -0
  231. package/locales/ru.d.mts +12 -0
  232. package/locales/ru.mjs +237 -0
  233. package/locales/rw.d.mts +6 -0
  234. package/locales/rw.mjs +108 -0
  235. package/locales/sd.d.mts +6 -0
  236. package/locales/sd.mjs +108 -0
  237. package/locales/se.d.mts +6 -0
  238. package/locales/se.mjs +108 -0
  239. package/locales/si.d.mts +6 -0
  240. package/locales/si.mjs +108 -0
  241. package/locales/sk.d.mts +6 -0
  242. package/locales/sk.mjs +168 -0
  243. package/locales/sl.d.mts +6 -0
  244. package/locales/sl.mjs +177 -0
  245. package/locales/sq.d.mts +6 -0
  246. package/locales/sq.mjs +108 -0
  247. package/locales/sr-cyrl.d.mts +9 -0
  248. package/locales/sr-cyrl.mjs +174 -0
  249. package/locales/sr.d.mts +6 -0
  250. package/locales/sr.mjs +186 -0
  251. package/locales/ss.d.mts +6 -0
  252. package/locales/ss.mjs +110 -0
  253. package/locales/sv-fi.d.mts +9 -0
  254. package/locales/sv-fi.mjs +25 -0
  255. package/locales/sv.d.mts +6 -0
  256. package/locales/sv.mjs +111 -0
  257. package/locales/sw.d.mts +6 -0
  258. package/locales/sw.mjs +108 -0
  259. package/locales/ta.d.mts +6 -0
  260. package/locales/ta.mjs +139 -0
  261. package/locales/te.d.mts +6 -0
  262. package/locales/te.mjs +111 -0
  263. package/locales/tet.d.mts +6 -0
  264. package/locales/tet.mjs +111 -0
  265. package/locales/tg.d.mts +6 -0
  266. package/locales/tg.mjs +127 -0
  267. package/locales/th.d.mts +6 -0
  268. package/locales/th.mjs +108 -0
  269. package/locales/tk.d.mts +6 -0
  270. package/locales/tk.mjs +135 -0
  271. package/locales/tl-ph.d.mts +6 -0
  272. package/locales/tl-ph.mjs +108 -0
  273. package/locales/tlh.d.mts +6 -0
  274. package/locales/tlh.mjs +155 -0
  275. package/locales/tr.d.mts +6 -0
  276. package/locales/tr.mjs +135 -0
  277. package/locales/tzl.d.mts +6 -0
  278. package/locales/tzl.mjs +125 -0
  279. package/locales/tzm-latn.d.mts +9 -0
  280. package/locales/tzm-latn.mjs +68 -0
  281. package/locales/tzm.d.mts +6 -0
  282. package/locales/tzm.mjs +108 -0
  283. package/locales/ug-cn.d.mts +6 -0
  284. package/locales/ug-cn.mjs +113 -0
  285. package/locales/uk.d.mts +6 -0
  286. package/locales/uk.mjs +199 -0
  287. package/locales/ur.d.mts +6 -0
  288. package/locales/ur.mjs +110 -0
  289. package/locales/uz-latn.d.mts +9 -0
  290. package/locales/uz-latn.mjs +68 -0
  291. package/locales/uz.d.mts +6 -0
  292. package/locales/uz.mjs +108 -0
  293. package/locales/vi.d.mts +6 -0
  294. package/locales/vi.mjs +108 -0
  295. package/locales/x-pseudo.d.mts +6 -0
  296. package/locales/x-pseudo.mjs +111 -0
  297. package/locales/yo.d.mts +6 -0
  298. package/locales/yo.mjs +108 -0
  299. package/locales/zh-cn.d.mts +9 -0
  300. package/locales/zh-cn.mjs +12 -0
  301. package/locales/zh-hk.d.mts +9 -0
  302. package/locales/zh-hk.mjs +21 -0
  303. package/locales/zh-mo.d.mts +9 -0
  304. package/locales/zh-mo.mjs +21 -0
  305. package/locales/zh-tw.d.mts +9 -0
  306. package/locales/zh-tw.mjs +21 -0
  307. package/locales/zh.d.mts +12 -0
  308. package/locales/zh.mjs +129 -0
  309. package/package.json +61 -29
  310. package/plugins/advancedFormat/index.d.mts +6 -0
  311. package/plugins/advancedFormat/index.mjs +18 -0
  312. package/plugins/advancedParse/index.d.mts +6 -0
  313. package/plugins/advancedParse/index.mjs +407 -0
  314. package/plugins/calendar/index.d.mts +12 -0
  315. package/plugins/calendar/index.mjs +32 -0
  316. package/plugins/dayOfYear/index.d.mts +12 -0
  317. package/plugins/dayOfYear/index.mjs +11 -0
  318. package/plugins/duration/index.d.mts +78 -0
  319. package/plugins/duration/index.mjs +477 -0
  320. package/plugins/isBetween/index.d.mts +22 -0
  321. package/plugins/isBetween/index.mjs +15 -0
  322. package/plugins/isLeapYear/index.d.mts +11 -0
  323. package/plugins/isLeapYear/index.mjs +10 -0
  324. package/plugins/isSameOrAfter/index.d.mts +11 -0
  325. package/plugins/isSameOrAfter/index.mjs +9 -0
  326. package/plugins/isSameOrBefore/index.d.mts +11 -0
  327. package/plugins/isSameOrBefore/index.mjs +9 -0
  328. package/plugins/isToday/index.d.mts +11 -0
  329. package/plugins/isToday/index.mjs +11 -0
  330. package/plugins/isTomorrow/index.d.mts +11 -0
  331. package/plugins/isTomorrow/index.mjs +13 -0
  332. package/plugins/isYesterday/index.d.mts +11 -0
  333. package/plugins/isYesterday/index.mjs +13 -0
  334. package/plugins/isoWeek/index.d.mts +19 -0
  335. package/plugins/isoWeek/index.mjs +228 -0
  336. package/plugins/locale/index.d.mts +104 -0
  337. package/plugins/locale/index.mjs +141 -0
  338. package/plugins/localeData/index.d.mts +6 -0
  339. package/plugins/localeData/index.mjs +155 -0
  340. package/plugins/localizedFormat/index.d.mts +6 -0
  341. package/plugins/localizedFormat/index.mjs +83 -0
  342. package/plugins/localizedParse/index.d.mts +6 -0
  343. package/plugins/localizedParse/index.mjs +217 -0
  344. package/plugins/minMax/index.d.mts +12 -0
  345. package/plugins/minMax/index.mjs +21 -0
  346. package/plugins/objectSupport/index.d.mts +6 -0
  347. package/plugins/objectSupport/index.mjs +99 -0
  348. package/plugins/pluralGetSet/index.d.mts +18 -0
  349. package/plugins/pluralGetSet/index.mjs +15 -0
  350. package/plugins/quarterOfYear/index.d.mts +14 -0
  351. package/plugins/quarterOfYear/index.mjs +51 -0
  352. package/plugins/relativeTime/index.d.mts +47 -0
  353. package/plugins/relativeTime/index.mjs +187 -0
  354. package/plugins/timezone/index.d.mts +6 -0
  355. package/plugins/timezone/index.mjs +456 -0
  356. package/plugins/toArray/index.d.mts +11 -0
  357. package/plugins/toArray/index.mjs +17 -0
  358. package/plugins/toObject/index.d.mts +19 -0
  359. package/plugins/toObject/index.mjs +17 -0
  360. package/plugins/utc/index.d.mts +18 -0
  361. package/plugins/utc/index.mjs +192 -0
  362. package/plugins/week/index.d.mts +19 -0
  363. package/plugins/week/index.mjs +350 -0
  364. package/EsDay-KXQgnL1r.d.ts +0 -89
  365. package/chunk-MLKGABMK.js +0 -7
  366. package/chunk-NUV73YDM.js +0 -60
  367. package/chunk-SQBPUYUY.js +0 -140
  368. package/index.d.ts +0 -6
  369. package/index.js +0 -310
  370. package/locales/en.d.ts +0 -6
  371. package/locales/en.js +0 -1
  372. package/locales/zh.d.ts +0 -6
  373. package/locales/zh.js +0 -64
  374. package/plugins/customParseFormat/index.d.ts +0 -5
  375. package/plugins/customParseFormat/index.js +0 -159
  376. package/plugins/isToday/index.d.ts +0 -10
  377. package/plugins/isToday/index.js +0 -8
  378. package/plugins/locale/index.d.ts +0 -75
  379. package/plugins/locale/index.js +0 -70
  380. package/plugins/utc/index.d.ts +0 -22
  381. package/plugins/utc/index.js +0 -40
@@ -0,0 +1,187 @@
1
+ import { p as constants_default } from "../../chunks/BkjWOpMU.js";
2
+ import { t as createInstanceFromExist } from "../../chunks/Shk32pTP.js";
3
+
4
+ //#region src/plugins/relativeTime/index.ts
5
+ const relativeTimePlugin = (options, dayClass, dayFactory) => {
6
+ const defaultRelativeTimeDef = {
7
+ future: "in %s",
8
+ past: "%s ago",
9
+ s: "a few seconds",
10
+ ss: "%d seconds",
11
+ m: "a minute",
12
+ mm: "%d minutes",
13
+ h: "an hour",
14
+ hh: "%d hours",
15
+ d: "a day",
16
+ dd: "%d days",
17
+ w: "a week",
18
+ ww: "%d weeks",
19
+ M: "a month",
20
+ MM: "%d months",
21
+ y: "a year",
22
+ yy: "%d years"
23
+ };
24
+ const defaultThresholds = {
25
+ ss: 44,
26
+ s: 45,
27
+ m: 45,
28
+ h: 22,
29
+ d: 26,
30
+ w: null,
31
+ M: 11
32
+ };
33
+ dayFactory.defaultThresholds = () => structuredClone(defaultThresholds);
34
+ const thresholds = options.thresholds ?? defaultThresholds;
35
+ dayFactory.globalThresholds = () => structuredClone(thresholds);
36
+ /**
37
+ * Format object containing a time difference as human readable length of time.
38
+ * @param diffAsUnits - object containing the time difference calculated for different units
39
+ * @param withoutSuffix - format without 'in ---' or '... ago'
40
+ * @param locale - locale to use to get format definitions for relativeTime
41
+ * @param thresholds - thresholds, which define when a unit is considered a minute, an hour and so on
42
+ * @returns difference formatted as human string (e.g. 5 days ago)
43
+ */
44
+ function formatDifference(diffAsUnits, withoutSuffix, locale, thresholds = defaultThresholds) {
45
+ const isFuture = diffAsUnits.s > 0;
46
+ const relativeTimeDef = locale?.relativeTime ?? defaultRelativeTimeDef;
47
+ let out = "";
48
+ let selectedKeyAndValue = {
49
+ key: "",
50
+ value: 0
51
+ };
52
+ if (rounding(abs(diffAsUnits.s)) <= (thresholds.ss ?? 0)) {
53
+ selectedKeyAndValue.key = "s";
54
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.s));
55
+ } else if (rounding(abs(diffAsUnits.s)) < (thresholds.s ?? -1)) {
56
+ selectedKeyAndValue.key = "ss";
57
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.s));
58
+ } else if (rounding(abs(diffAsUnits.m)) <= 1) {
59
+ selectedKeyAndValue.key = "m";
60
+ selectedKeyAndValue.value = void 0;
61
+ } else if (rounding(abs(diffAsUnits.m)) < (thresholds.m ?? -1)) {
62
+ selectedKeyAndValue.key = "mm";
63
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.m));
64
+ } else if (rounding(abs(diffAsUnits.h)) <= 1) {
65
+ selectedKeyAndValue.key = "h";
66
+ selectedKeyAndValue.value = void 0;
67
+ } else if (rounding(abs(diffAsUnits.h)) < (thresholds.h ?? -1)) {
68
+ selectedKeyAndValue.key = "hh";
69
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.h));
70
+ } else if (rounding(abs(diffAsUnits.d)) <= 1) {
71
+ selectedKeyAndValue.key = "d";
72
+ selectedKeyAndValue.value = void 0;
73
+ } else if (rounding(abs(diffAsUnits.d)) < (thresholds.d ?? -1)) {
74
+ selectedKeyAndValue.key = "dd";
75
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.d));
76
+ } else if (thresholds.w !== null && rounding(abs(diffAsUnits.w)) <= 1) {
77
+ selectedKeyAndValue.key = "w";
78
+ selectedKeyAndValue.value = void 0;
79
+ } else if (thresholds.w !== null && rounding(abs(diffAsUnits.w)) < (thresholds.w ?? -1)) {
80
+ selectedKeyAndValue.key = "ww";
81
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.w));
82
+ } else if (rounding(abs(diffAsUnits.M)) <= 1) {
83
+ selectedKeyAndValue.key = "M";
84
+ selectedKeyAndValue.value = void 0;
85
+ } else if (rounding(abs(diffAsUnits.M)) < (thresholds.M ?? -1)) {
86
+ selectedKeyAndValue.key = "MM";
87
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.M));
88
+ } else if (rounding(abs(diffAsUnits.y)) <= 1) {
89
+ selectedKeyAndValue.key = "y";
90
+ selectedKeyAndValue.value = void 0;
91
+ } else {
92
+ selectedKeyAndValue.key = "yy";
93
+ selectedKeyAndValue.value = rounding(abs(diffAsUnits.y));
94
+ }
95
+ const format = relativeTimeDef[selectedKeyAndValue.key];
96
+ const outputDiffAbs = rounding(abs(selectedKeyAndValue.value ?? 1));
97
+ out = typeof format === "string" ? format.replace("%d", `${outputDiffAbs}`) : format(outputDiffAbs, withoutSuffix, selectedKeyAndValue.key, isFuture);
98
+ const postFormat = locale?.postFormat;
99
+ if (postFormat) out = postFormat(out);
100
+ if (withoutSuffix) return out;
101
+ const suffix = isFuture ? relativeTimeDef.future : relativeTimeDef.past;
102
+ return typeof suffix === "function" ? suffix(out, withoutSuffix, isFuture ? "future" : "past", isFuture) : suffix.replace("%s", out);
103
+ }
104
+ dayFactory.formatDifference = formatDifference;
105
+ const proto = dayClass.prototype;
106
+ const abs = Math.abs;
107
+ let rounding = options.rounding ?? Math.round;
108
+ /**
109
+ * Set a threshold for relative time strings
110
+ * @param unit - unit of threshold to get / set (ss,s,m,h,d,w,M)
111
+ * @param limit - new threshold value
112
+ * @returns false=unknown unit; true=threshold successfully set; current threshold (number | null)
113
+ */
114
+ dayFactory.relativeTimeThreshold = (unit, limit) => {
115
+ if (thresholds[unit] === void 0) return false;
116
+ if (limit === void 0) return thresholds[unit];
117
+ thresholds[unit] = limit;
118
+ if (unit === "s") if (limit !== null) thresholds.ss = limit - 1;
119
+ else thresholds.ss = null;
120
+ return true;
121
+ };
122
+ /**
123
+ * Gets or sets the rounding function for relative time strings
124
+ * @param roundingFunction - rounding function
125
+ * @returns - the rounding function (getter) or true=rounding function successfully set
126
+ */
127
+ dayFactory.relativeTimeRounding = (roundingFunction) => {
128
+ if (roundingFunction === void 0) return rounding;
129
+ if (typeof roundingFunction === "function") {
130
+ rounding = roundingFunction;
131
+ return true;
132
+ }
133
+ return false;
134
+ };
135
+ /**
136
+ * Calculate the difference between instance and referenceDate in given units
137
+ * as fractional value for 'from' and 'to'
138
+ * @param instance - date to calculate difference for
139
+ * @param referenceDate - base date for calculating the difference
140
+ * @param unit - unit of the difference
141
+ * @param isFrom - difference for 'from'?
142
+ * @returns difference as float
143
+ */
144
+ function differenceInUnits(instance, referenceDate, unit, isFrom) {
145
+ return isFrom ? referenceDate.diff(instance, unit, true) : instance.diff(referenceDate, unit, true);
146
+ }
147
+ /**
148
+ * Format instance date as relative to reference date as
149
+ * human readable length of time.
150
+ * @param reference - date the output relates to
151
+ * @param withoutSuffix - format without 'in ---' or '... ago'
152
+ * @param this - date to format
153
+ * @param isFrom - format as 'from' or 'fromNow'
154
+ * @returns difference formatted as human string (e.g. 5 days ago)
155
+ */
156
+ function fromToBase(reference, withoutSuffix, isFrom) {
157
+ const referenceDate = dayFactory(reference);
158
+ if (!(this.isValid() && referenceDate.isValid())) return constants_default.INVALID_DATE_STRING;
159
+ const locale = this.localeObject?.();
160
+ return formatDifference({
161
+ s: differenceInUnits(this, referenceDate, "s", isFrom),
162
+ m: differenceInUnits(this, referenceDate, "m", isFrom),
163
+ h: differenceInUnits(this, referenceDate, "h", isFrom),
164
+ d: differenceInUnits(this, referenceDate, "d", isFrom),
165
+ w: differenceInUnits(this, referenceDate, "w", isFrom),
166
+ M: differenceInUnits(this, referenceDate, "M", isFrom),
167
+ y: differenceInUnits(this, referenceDate, "y", isFrom)
168
+ }, withoutSuffix, locale, thresholds);
169
+ }
170
+ proto.to = function(referenceDate, withoutSuffix) {
171
+ return fromToBase.call(this, referenceDate, withoutSuffix ?? false, true);
172
+ };
173
+ proto.from = function(referenceDate, withoutSuffix) {
174
+ return fromToBase.call(this, referenceDate, withoutSuffix ?? false, false);
175
+ };
176
+ proto.toNow = function(withoutSuffix) {
177
+ const now = createInstanceFromExist(/* @__PURE__ */ new Date(), this);
178
+ return this.to(now, withoutSuffix);
179
+ };
180
+ proto.fromNow = function(withoutSuffix) {
181
+ const now = createInstanceFromExist(/* @__PURE__ */ new Date(), this);
182
+ return this.from(now, withoutSuffix);
183
+ };
184
+ };
185
+
186
+ //#endregion
187
+ export { relativeTimePlugin as default };
@@ -0,0 +1,6 @@
1
+ import { o as EsDayPlugin } from "../../chunks/CODi8AFH.js";
2
+
3
+ //#region src/plugins/timezone/index.d.ts
4
+ declare const timezonePLugin: EsDayPlugin<{}>;
5
+ //#endregion
6
+ export { timezonePLugin as default };
@@ -0,0 +1,456 @@
1
+ import { p as constants_default } from "../../chunks/BkjWOpMU.js";
2
+ import { n as isEmptyObject, r as isObject } from "../../chunks/v_QBn7Xm.js";
3
+ import { n as normalizeUnitWithPlurals } from "../../chunks/AyQQ6US-.js";
4
+ import { t as esday } from "../../chunks/CXWzCl3n.js";
5
+
6
+ //#region src/plugins/timezone/timezone-util.ts
7
+ /**
8
+ * Cache for Intl.DateTimeFormat instances for formatting date and time
9
+ * used to improve performance.
10
+ * The key is a combination of timezone and timeZoneName.
11
+ */
12
+ const dtfCacheDateTime = {};
13
+ const dtfCacheTimezoneName = {};
14
+ const TzDefaultTimezoneLocale = "en-US";
15
+ /**
16
+ * Get a cached or newly created Intl.DateTimeFormat instance for date/time formats.
17
+ *
18
+ * This function caches Intl.DateTimeFormat objects since their creation
19
+ * is relatively slow. It returns a formatter configured for date and time values
20
+ * using the given timezone.
21
+ *
22
+ * @param timezone - The IANA timezone identifier (e.g., "Asia/Shanghai").
23
+ * @returns A cached or new Intl.DateTimeFormat instance.
24
+ */
25
+ function getDateTimeFormat(timezone) {
26
+ const formatOptions = {
27
+ hour12: false,
28
+ hourCycle: "h23",
29
+ year: "numeric",
30
+ month: "2-digit",
31
+ day: "2-digit",
32
+ hour: "2-digit",
33
+ minute: "2-digit",
34
+ second: "2-digit",
35
+ weekday: "short"
36
+ };
37
+ if (timezone.length > 0) formatOptions["timeZone"] = timezone;
38
+ const key = `${timezone}|formatDateTime`;
39
+ let dtf = dtfCacheDateTime[key];
40
+ if (!dtf) {
41
+ dtf = new Intl.DateTimeFormat("en-US", formatOptions);
42
+ dtfCacheDateTime[key] = dtf;
43
+ }
44
+ return dtf;
45
+ }
46
+ /**
47
+ * Get a cached or newly created Intl.DateTimeFormat instance for timezone name formats.
48
+ *
49
+ * This function caches Intl.DateTimeFormat objects since their creation
50
+ * is relatively slow. It returns a formatter configured for timezone names using
51
+ * the given timezone and locale name.
52
+ *
53
+ * @param timezone - The IANA timezone identifier (e.g., "Asia/Shanghai").
54
+ * @param localeName - Optional settings for the name of the locale to use.
55
+ * @returns A cached or new Intl.DateTimeFormat instance.
56
+ */
57
+ function getTimezoneNameFormat(timezone, localeName = TzDefaultTimezoneLocale) {
58
+ const formatOptions = {
59
+ year: "numeric",
60
+ month: "2-digit",
61
+ timeZoneName: "short"
62
+ };
63
+ if (timezone.length > 0) formatOptions["timeZone"] = timezone;
64
+ const key = `${timezone}|localeName|timezoneName`;
65
+ let dtf = dtfCacheTimezoneName[key];
66
+ if (!dtf) {
67
+ dtf = new Intl.DateTimeFormat(localeName, formatOptions);
68
+ dtfCacheTimezoneName[key] = dtf;
69
+ }
70
+ return dtf;
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/plugins/timezone/index.ts
75
+ /**
76
+ * timezone plugin
77
+ *
78
+ * This plugin adds the 'tz' method to the EsDay class.
79
+ * This plugin adds the 'tz' method/object to the esday class with the methods 'setDefault', 'getDefault' and 'guess'.
80
+ *
81
+ * This plugin adds the formatting tokens 'z' and 'Z' to EsDay.
82
+ *
83
+ * This plugin requires the 'utc' plugin.
84
+ * When parsing with a locale then the 'advancedParse' plugin, the 'localizedParse' plugin
85
+ * and at least one registered locale.
86
+ * This plugin can handle the 'locale' plugin.
87
+ *
88
+ * esday parameters in '$conf' defined in timezone plugin:
89
+ * timezone name of the timezone of this instance
90
+ */
91
+ const UNIT_ARRAY_MAP = {
92
+ year: 0,
93
+ month: 1,
94
+ date: 2,
95
+ hour: 3,
96
+ minute: 4,
97
+ second: 5
98
+ };
99
+ const maxDstDiff = 7200 * 1e3;
100
+ const typeToPos = {
101
+ year: 0,
102
+ month: 1,
103
+ day: 2,
104
+ hour: 3,
105
+ minute: 4,
106
+ second: 5
107
+ };
108
+ const matchContainsOffset = /^(\d{4})[-/](\d{1,2})[-/](\d{0,2}).*(([+-]\d\d:?(\d\d)?)$|Z$)/;
109
+ /**
110
+ * Generate formatted date parts for a given timestamp and timezone.
111
+ *
112
+ * This function creates a Date object from the given timestamp,
113
+ * retrieves a cached or new Intl.DateTimeFormat instance using
114
+ * the provided timezone and returns the formatted parts
115
+ * (year, month, day-of-month, hour, minute, second, weekday)
116
+ *
117
+ * @param timestamp - The timestamp in milliseconds since the Unix epoch.
118
+ * @param timezone - The IANA timezone identifier (e.g., "Asia/Shanghai").
119
+ * @returns An array of formatted date parts.
120
+ */
121
+ function makeFormatPartsDateTime(timestamp, timezone) {
122
+ const dtf = getDateTimeFormat(timezone);
123
+ const date = new Date(timestamp);
124
+ return dtf.formatToParts(date);
125
+ }
126
+ /**
127
+ * Do we have to convert parsed instance to another timezone?
128
+ * @param input - input value to be parsed by plugin timezone
129
+ * @returns true: result of parsing of input value must be converted to timezone
130
+ */
131
+ function convertRequired(input) {
132
+ const requiresObjectSupport = isObject(input) && !(input instanceof Date) && input !== null && !isEmptyObject(input);
133
+ return typeof input !== "string" && !Array.isArray(input) && !requiresObjectSupport;
134
+ }
135
+ /**
136
+ * Convert en-US short weekday names to a number using values like Date.getDay() does.
137
+ * @param shortWeekdayName - short weekday name (in locale en-US)
138
+ * @returns - number indicating the weekday (0=Sunday, 1=Monday, ...)
139
+ */
140
+ function weekdayNameToNumber(shortWeekdayName) {
141
+ switch (shortWeekdayName) {
142
+ case "Sun": return 0;
143
+ case "Mon": return 1;
144
+ case "Tue": return 2;
145
+ case "Wed": return 3;
146
+ case "Thu": return 4;
147
+ case "Fri": return 5;
148
+ case "Sat": return 6;
149
+ default: return -1;
150
+ }
151
+ }
152
+ /**
153
+ * Get the date components (year, month, day ...) of the given timestamp,
154
+ * if formatted in the given timezone.
155
+ * The function returns an array with the values for
156
+ * [year, month, day-of-month, hour, minute, second, weekday].
157
+ * 'month' is 1..12; 'day-of-month' is 1..31, 'weekday' is 0..6.
158
+ * @param timestamp - timestamp to convert
159
+ * @param timezone - timezone to use for formatting
160
+ * @returns array of numbers with the date components of the timestamp in the timezone
161
+ */
162
+ function timestampToDateTimeComponents(timestamp, timezone) {
163
+ const formatResult = makeFormatPartsDateTime(timestamp, timezone);
164
+ const filled = [];
165
+ let weekdayNumber = -1;
166
+ for (let i = 0; i < formatResult.length; i += 1) {
167
+ const { type, value } = formatResult[i];
168
+ if (type === "weekday") {
169
+ weekdayNumber = weekdayNameToNumber(value);
170
+ continue;
171
+ }
172
+ const pos = typeToPos[type];
173
+ if (pos >= 0) filled[pos] = Number.parseInt(value, 10);
174
+ filled[6] = weekdayNumber;
175
+ }
176
+ return filled;
177
+ }
178
+ /**
179
+ * Get the formatted timezone name of the given timestamp, if formatted in
180
+ * the given timezone.
181
+ * The function returns the short name of the timezone using the given locale.
182
+ * 'month' is 1..12; 'day-of-month' is 1..31, 'weekday' is 0..6.
183
+ * @param timestamp - timestamp to convert
184
+ * @param timezone - timezone to use for conversion
185
+ * @param timezone - timezone to use for conversion
186
+ * @returns array of numbers with the date components of the timestamp in the timezone
187
+ */
188
+ function timestampToTimezoneName(timestamp, timezone, locale) {
189
+ const dtf = getTimezoneNameFormat(timezone, locale);
190
+ const date = new Date(timestamp);
191
+ const formatResult = dtf.formatToParts(date);
192
+ let timezoneNameShort = timezone;
193
+ /* istanbul ignore else -- @preserve */
194
+ if (formatResult.length >= 4 && formatResult[4].type === "timeZoneName") timezoneNameShort = formatResult[4].value;
195
+ return timezoneNameShort;
196
+ }
197
+ /**
198
+ * Calculate the new basic values for year, month etc. when using the "set" method.
199
+ * These values must be adjusted to the current timezone.
200
+ * @param dateComponents - array with the components of the formatted timestamp (year, month, ...)
201
+ * @param currentMs - milliseconds of the current timestamp (0..999)
202
+ * @param unit - normalized unit to set
203
+ * @param values - value to set (or values, if applicable e.g. for year)
204
+ * @returns literal object with year, month etc. after setting the new value(s)
205
+ */
206
+ function calculateBaseComponentsForSet(dateComponents, currentMs, unit, values) {
207
+ let year = dateComponents[0];
208
+ let month = dateComponents[1] - 1;
209
+ let day = dateComponents[2];
210
+ let hour = dateComponents[3];
211
+ let minute = dateComponents[4];
212
+ let second = dateComponents[5];
213
+ let ms = currentMs;
214
+ const mainValue = values[0];
215
+ if (unit === constants_default.YEAR) {
216
+ year = mainValue;
217
+ if (values.length > 1) month = values[1];
218
+ if (values.length > 2) day = values[2];
219
+ } else if (unit === constants_default.MONTH) {
220
+ month = mainValue;
221
+ if (values.length > 1) day = values[1];
222
+ } else if (unit === constants_default.DAY) {
223
+ const currentWeekday = dateComponents[6];
224
+ day += mainValue - currentWeekday;
225
+ } else if (unit === constants_default.DAY_OF_MONTH) day = mainValue;
226
+ else if (unit === constants_default.HOUR) hour = mainValue;
227
+ else if (unit === constants_default.MIN) minute = mainValue;
228
+ else if (unit === constants_default.SECOND) second = mainValue;
229
+ else if (unit === constants_default.MS) ms = mainValue;
230
+ if (unit === constants_default.YEAR || unit === constants_default.MONTH) {
231
+ const lastDay = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
232
+ if (day > lastDay) day = lastDay;
233
+ }
234
+ let valuesIndex = 1;
235
+ if (unit === constants_default.HOUR && values.length > valuesIndex) minute = values[valuesIndex++];
236
+ if ((unit === constants_default.HOUR || unit === constants_default.MIN) && values.length > valuesIndex) second = values[valuesIndex++];
237
+ if ((unit === constants_default.HOUR || unit === constants_default.MIN || unit === constants_default.SECOND) && values.length > valuesIndex) ms = values[valuesIndex++];
238
+ return {
239
+ year,
240
+ month,
241
+ day,
242
+ hour,
243
+ minute,
244
+ second,
245
+ ms
246
+ };
247
+ }
248
+ /**
249
+ * Gets the timezone of the given date formatted in the short form (e.g. 'PST')
250
+ * @param sourceDate - date to format the timezone for
251
+ * @returns the short form of the timezone of the given sourceDate
252
+ */
253
+ function formatTimezoneShort(sourceDate) {
254
+ const timezone = sourceDate.tz();
255
+ const localeName = sourceDate.locale?.() ?? esday.locale?.();
256
+ return timestampToTimezoneName(sourceDate.valueOf(), timezone, localeName);
257
+ }
258
+ const timezonePLugin = (_, dayClass, esdayFactory) => {
259
+ const noTimezone = "";
260
+ let defaultTimezone;
261
+ /**
262
+ * Get timezone offset for timestamp in given timezone
263
+ * @param timestamp - timestamp to use
264
+ * @param timezone - timezone to calculate offset for
265
+ * @returns utc offset for timestamp in given timezone
266
+ */
267
+ const tzOffset = (timestamp, timezone) => {
268
+ const filled = timestampToDateTimeComponents(timestamp, timezone);
269
+ const utcString = `${filled[0]}-${filled[1]}-${filled[2]} ${filled[3]}:${filled[4]}:${filled[5]}:000`;
270
+ const utcTs = esdayFactory.utc(utcString).valueOf();
271
+ let timestampAsEpoch = timestamp.valueOf();
272
+ const msOfTimestamp = timestampAsEpoch % 1e3;
273
+ timestampAsEpoch -= msOfTimestamp;
274
+ return (utcTs - timestampAsEpoch) / (60 * 1e3);
275
+ };
276
+ /**
277
+ * Move to the earlier date in an DST overlap, if we are in an overlap. Otherwise return input date.
278
+ * The return value is an literal object in the form of {timestampFixed, tzOffsetFixed, isInOverlap}.
279
+ * @param timestampOriginal - timestamp to be fixed
280
+ * @param tzOffsetOriginal - tzOffset of timestampOriginal
281
+ * @param timezone - timezone to use
282
+ * @returns literal object containing fixed date (or original date, if we are not in an overlap)
283
+ */
284
+ const fixOverlap = (timestampOriginal, tzOffsetOriginal, timezone) => {
285
+ let timestampFixed = timestampOriginal;
286
+ let tzOffsetFixed = tzOffsetOriginal;
287
+ let isInOverlap = false;
288
+ const tzOffsetPreDst = tzOffset(timestampOriginal - maxDstDiff, timezone);
289
+ if (tzOffsetPreDst > tzOffsetOriginal) {
290
+ timestampFixed = timestampOriginal - (tzOffsetPreDst - tzOffsetOriginal) * 60 * 1e3;
291
+ tzOffsetFixed = tzOffset(timestampFixed, timezone);
292
+ if (tzOffsetFixed === tzOffsetOriginal) {
293
+ timestampFixed = timestampOriginal;
294
+ tzOffsetFixed = tzOffsetOriginal;
295
+ } else isInOverlap = true;
296
+ }
297
+ return {
298
+ timestampFixed,
299
+ tzOffsetFixed,
300
+ isInOverlap
301
+ };
302
+ };
303
+ /**
304
+ * Change the timestamp and timezone offset of a timestamp to change the timezone while keeping the time value.
305
+ * @param timestampOriginal - timestamp to fix the offset for, if necessary
306
+ * @param tzOffsetSource - tzOffset of the originalTimestamp in the source timezone
307
+ * @param tzOffsetTarget - tzOffset of the originalTimestamp in the target timezone
308
+ * @param tzTarget - timezone to use
309
+ * @returns array with updated timestamp and fixed offset
310
+ */
311
+ const fixOffsetConvert = (timestampOriginal, tzOffsetSource, tzOffsetTarget, tzTarget) => {
312
+ const timestampGuess1 = timestampOriginal - (tzOffsetTarget - tzOffsetSource) * 60 * 1e3;
313
+ const tzOffsetGuess1 = tzOffset(timestampGuess1, tzTarget);
314
+ if (tzOffsetGuess1 === tzOffsetTarget) {
315
+ const { timestampFixed, tzOffsetFixed } = fixOverlap(timestampGuess1, tzOffsetGuess1, tzTarget);
316
+ return [timestampFixed, tzOffsetFixed];
317
+ }
318
+ const timestampGuess2 = timestampGuess1 - (tzOffsetGuess1 - tzOffsetTarget) * 60 * 1e3;
319
+ const tzOffsetGuess2 = tzOffset(timestampGuess2, tzTarget);
320
+ if (tzOffsetGuess2 === tzOffsetGuess1) return [timestampGuess2, tzOffsetGuess2];
321
+ else if (tzOffsetGuess1 < tzOffsetTarget) return [timestampGuess2, tzOffsetGuess2];
322
+ else return [timestampGuess1, tzOffsetGuess1];
323
+ };
324
+ esdayFactory.tz = (input, ...others) => {
325
+ let timezone = defaultTimezone;
326
+ if (others.length > 0) timezone = others.pop();
327
+ const parsedInput = esdayFactory.utc(input, ...others);
328
+ if (!parsedInput.isValid()) return parsedInput;
329
+ const offsetParsedInput = tzOffset(parsedInput.valueOf(), timezone ?? noTimezone);
330
+ if (convertRequired(input) || typeof input === "string" && matchContainsOffset.test(input)) return parsedInput.tz(timezone);
331
+ const [targetTimestamp, targetOffset] = fixOffsetConvert(parsedInput.valueOf(), 0, offsetParsedInput, timezone ?? noTimezone);
332
+ const result = esdayFactory.utc(targetTimestamp, ...others);
333
+ result["$conf"].utcOffset = targetOffset;
334
+ result["$conf"].localOffset = result.toDate().getTimezoneOffset();
335
+ result["$conf"].utc = targetOffset === 0;
336
+ if (result["$conf"].localeName !== void 0 && parsedInput["$conf"].localeName !== void 0) result["$conf"].localeName = parsedInput["$conf"].localeName;
337
+ result["$conf"].timezone = timezone;
338
+ return result;
339
+ };
340
+ esdayFactory.tz.guess = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
341
+ esdayFactory.tz.setDefault = (timezone) => {
342
+ defaultTimezone = timezone;
343
+ };
344
+ esdayFactory.tz.getDefault = () => {
345
+ return defaultTimezone;
346
+ };
347
+ const proto = dayClass.prototype;
348
+ proto.tz = function(timezone, keepLocalTime) {
349
+ if (timezone === void 0) return this["$conf"].timezone;
350
+ const result = this.clone();
351
+ const tzOffsetTarget = tzOffset(this.valueOf(), timezone);
352
+ const localOffset = this.toDate().getTimezoneOffset();
353
+ result["$conf"].localOffset = localOffset;
354
+ result["$conf"].utcOffset = tzOffsetTarget;
355
+ result["$conf"].utc = tzOffsetTarget === 0;
356
+ result["$conf"].timezone = timezone;
357
+ if (keepLocalTime) {
358
+ const timestampSource = result.valueOf();
359
+ let tzOffsetSource = 0;
360
+ if (!this["$conf"].utc) tzOffsetSource = this["$conf"].timezone ? Number(this["$conf"].utcOffset) : -1 * localOffset;
361
+ const [timestampFixed, tzOffsetFixed] = fixOffsetConvert(timestampSource, tzOffsetSource, tzOffsetTarget, timezone);
362
+ result["$conf"].utcOffset = tzOffsetFixed;
363
+ result["$conf"].utc = tzOffsetFixed === 0;
364
+ if (timestampSource !== timestampFixed) result.$d = new Date(timestampFixed);
365
+ }
366
+ return result;
367
+ };
368
+ const oldValueOf = proto.valueOf;
369
+ proto.valueOf = function() {
370
+ if (this["$conf"]?.timezone) return this.$d.valueOf();
371
+ return oldValueOf.call(this);
372
+ };
373
+ const oldGet = proto.get;
374
+ proto.get = function(unit) {
375
+ const normalizedUnit = normalizeUnitWithPlurals(unit);
376
+ if (normalizedUnit === constants_default.QUARTER || normalizedUnit === constants_default.WEEK || normalizedUnit === constants_default.ISOWEEK || this["$conf"]?.utc) return oldGet.call(this, unit);
377
+ if (this["$conf"]?.timezone) {
378
+ const timezone = this["$conf"].timezone;
379
+ const dateComponents = timestampToDateTimeComponents(this.valueOf(), timezone);
380
+ if (normalizedUnit === constants_default.MS) return this["$d"].getUTCMilliseconds();
381
+ else if (normalizedUnit === constants_default.MONTH) return dateComponents[1] - 1;
382
+ else if (normalizedUnit === constants_default.DAY) return dateComponents[6];
383
+ else return dateComponents[UNIT_ARRAY_MAP[normalizedUnit]];
384
+ }
385
+ return oldGet.call(this, unit);
386
+ };
387
+ const old$set = proto["$set"];
388
+ proto["$set"] = function(unit, values) {
389
+ if (isObject(unit)) return old$set.call(this, unit, values);
390
+ const timezone = this["$conf"]?.timezone;
391
+ if (!timezone) return old$set.call(this, unit, values);
392
+ const normalizedUnit = normalizeUnitWithPlurals(unit);
393
+ const { year, month, day, hour, minute, second, ms } = calculateBaseComponentsForSet(timestampToDateTimeComponents(this.valueOf(), timezone), this.valueOf() % 1e3, normalizedUnit, values);
394
+ const utcAsLocal = Date.UTC(year, month, day, hour, minute, second, ms);
395
+ const [timestampFixed, tzOffsetFixed] = fixOffsetConvert(utcAsLocal, 0, tzOffset(utcAsLocal, timezone), timezone);
396
+ this.$d = new Date(timestampFixed);
397
+ this["$conf"].utcOffset = tzOffsetFixed;
398
+ this["$conf"].localOffset = this.$d.getTimezoneOffset();
399
+ this["$conf"].utc = tzOffsetFixed === 0;
400
+ return this;
401
+ };
402
+ const oldStartOf = dayClass.prototype.startOf;
403
+ proto.startOf = function(units) {
404
+ if (!this["$conf"] || !this["$conf"]["timezone"]) return oldStartOf.call(this, units);
405
+ const withoutTz = esdayFactory(this.format("YYYY-MM-DD HH:mm:ss:SSS"));
406
+ return oldStartOf.call(withoutTz, units).tz(this["$conf"]["timezone"], true);
407
+ };
408
+ const oldEndOf = dayClass.prototype.endOf;
409
+ proto.endOf = function(units) {
410
+ if (!this["$conf"] || !this["$conf"]["timezone"]) return oldEndOf.call(this, units);
411
+ const withoutTz = esdayFactory(this.format("YYYY-MM-DD HH:mm:ss:SSS"));
412
+ return oldEndOf.call(withoutTz, units).tz(this["$conf"]["timezone"], true);
413
+ };
414
+ const oldAdd = proto.add;
415
+ proto.add = function(value, unit) {
416
+ if (isObject(value) || unit === void 0) return oldAdd.call(this, value, unit);
417
+ const newValue = oldAdd.call(this, value, unit);
418
+ if (!this["$conf"].timezone) return newValue;
419
+ const timezone = this["$conf"]["timezone"];
420
+ const timestamp = newValue.valueOf();
421
+ const tzOldOffset = tzOffset(timestamp, timezone);
422
+ const normalizedUnit = normalizeUnitWithPlurals(unit);
423
+ const timeUnits = [
424
+ constants_default.HOUR,
425
+ constants_default.MIN,
426
+ constants_default.SECOND,
427
+ constants_default.MS
428
+ ];
429
+ const { isInOverlap } = fixOverlap(timestamp, tzOldOffset, timezone);
430
+ if (timeUnits.includes(normalizedUnit) && isInOverlap) {
431
+ newValue["$conf"].utcOffset = tzOldOffset;
432
+ newValue["$conf"].utc = tzOldOffset === 0;
433
+ return newValue;
434
+ }
435
+ const [timestampFixed, tzOffsetFixed] = fixOffsetConvert(timestamp, tzOldOffset, tzOffset(timestamp, timezone), timezone);
436
+ newValue.$d = new Date(timestampFixed);
437
+ newValue["$conf"].utcOffset = tzOffsetFixed;
438
+ newValue["$conf"].localOffset = newValue.$d.getTimezoneOffset();
439
+ newValue["$conf"].utc = tzOffsetFixed === 0;
440
+ return newValue;
441
+ };
442
+ const oldSubtract = proto.subtract;
443
+ proto.subtract = function(value, unit) {
444
+ if (isObject(value) || unit === void 0) return oldSubtract.call(this, value, unit);
445
+ if (this["$conf"].timezone) return proto.add.call(this, -value, unit);
446
+ return oldSubtract.call(this, value, unit);
447
+ };
448
+ const additionalTokens = {
449
+ z: formatTimezoneShort,
450
+ zz: formatTimezoneShort
451
+ };
452
+ esdayFactory.addFormatTokenDefinitions(additionalTokens);
453
+ };
454
+
455
+ //#endregion
456
+ export { timezonePLugin as default };
@@ -0,0 +1,11 @@
1
+ import { o as EsDayPlugin } from "../../chunks/CODi8AFH.js";
2
+
3
+ //#region src/plugins/toArray/index.d.ts
4
+ declare module 'esday' {
5
+ interface EsDay {
6
+ toArray: () => [number, number, number, number, number, number, number];
7
+ }
8
+ }
9
+ declare const toArrayPlugin: EsDayPlugin<{}>;
10
+ //#endregion
11
+ export { toArrayPlugin as default };
@@ -0,0 +1,17 @@
1
+ //#region src/plugins/toArray/index.ts
2
+ const toArrayPlugin = (_, dayClass) => {
3
+ dayClass.prototype.toArray = function() {
4
+ return [
5
+ this.year(),
6
+ this.month(),
7
+ this.date(),
8
+ this.hour(),
9
+ this.minute(),
10
+ this.second(),
11
+ this.millisecond()
12
+ ];
13
+ };
14
+ };
15
+
16
+ //#endregion
17
+ export { toArrayPlugin as default };