chronos-date 1.0.2 → 1.1.1

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 (117) hide show
  1. package/dist/basic-DqKyujoj.mjs +382 -0
  2. package/dist/basic-DsQqC5nZ.cjs +466 -0
  3. package/dist/constants.cjs +43 -1
  4. package/dist/constants.d.cts +17 -1
  5. package/dist/constants.d.mts +17 -1
  6. package/dist/constants.mjs +21 -1
  7. package/dist/convert-DbgntRVW.cjs +49 -0
  8. package/dist/convert-mMaI4YP0.mjs +38 -0
  9. package/dist/greet-D07t2_e6.mjs +51 -0
  10. package/dist/greet-hjVsd2dt.cjs +56 -0
  11. package/dist/guards.cjs +140 -1
  12. package/dist/guards.d.cts +18 -2
  13. package/dist/guards.d.mts +18 -2
  14. package/dist/guards.mjs +131 -1
  15. package/dist/helpers-CQzi908i.cjs +278 -0
  16. package/dist/helpers-DEf4sevD.mjs +201 -0
  17. package/dist/index.cjs +1477 -1
  18. package/dist/index.d.cts +18 -2
  19. package/dist/index.d.mts +18 -2
  20. package/dist/index.mjs +1474 -1
  21. package/dist/non-primitives-D9zxCwX8.cjs +68 -0
  22. package/dist/non-primitives-DBtomDty.mjs +38 -0
  23. package/dist/plugins/banglaPlugin.cjs +137 -1
  24. package/dist/plugins/banglaPlugin.d.cts +19 -3
  25. package/dist/plugins/banglaPlugin.d.mts +19 -3
  26. package/dist/plugins/banglaPlugin.mjs +136 -1
  27. package/dist/plugins/businessPlugin.cjs +134 -1
  28. package/dist/plugins/businessPlugin.d.cts +17 -1
  29. package/dist/plugins/businessPlugin.d.mts +17 -1
  30. package/dist/plugins/businessPlugin.mjs +133 -1
  31. package/dist/plugins/dateRangePlugin.cjs +62 -1
  32. package/dist/plugins/dateRangePlugin.d.cts +19 -3
  33. package/dist/plugins/dateRangePlugin.d.mts +19 -3
  34. package/dist/plugins/dateRangePlugin.mjs +61 -1
  35. package/dist/plugins/dayPartPlugin.cjs +42 -1
  36. package/dist/plugins/dayPartPlugin.d.cts +17 -1
  37. package/dist/plugins/dayPartPlugin.d.mts +17 -1
  38. package/dist/plugins/dayPartPlugin.mjs +41 -1
  39. package/dist/plugins/durationPlugin.cjs +107 -1
  40. package/dist/plugins/durationPlugin.d.cts +17 -1
  41. package/dist/plugins/durationPlugin.d.mts +17 -1
  42. package/dist/plugins/durationPlugin.mjs +106 -1
  43. package/dist/plugins/fromNowPlugin.cjs +96 -1
  44. package/dist/plugins/fromNowPlugin.d.cts +17 -1
  45. package/dist/plugins/fromNowPlugin.d.mts +17 -1
  46. package/dist/plugins/fromNowPlugin.mjs +95 -1
  47. package/dist/plugins/greetingPlugin.cjs +35 -1
  48. package/dist/plugins/greetingPlugin.d.cts +17 -1
  49. package/dist/plugins/greetingPlugin.d.mts +17 -1
  50. package/dist/plugins/greetingPlugin.mjs +34 -1
  51. package/dist/plugins/palindromePlugin.cjs +38 -1
  52. package/dist/plugins/palindromePlugin.d.cts +17 -1
  53. package/dist/plugins/palindromePlugin.d.mts +17 -1
  54. package/dist/plugins/palindromePlugin.mjs +37 -1
  55. package/dist/plugins/relativeTimePlugin.cjs +90 -1
  56. package/dist/plugins/relativeTimePlugin.d.cts +17 -1
  57. package/dist/plugins/relativeTimePlugin.d.mts +17 -1
  58. package/dist/plugins/relativeTimePlugin.mjs +89 -1
  59. package/dist/plugins/roundPlugin.cjs +85 -1
  60. package/dist/plugins/roundPlugin.d.cts +17 -1
  61. package/dist/plugins/roundPlugin.d.mts +17 -1
  62. package/dist/plugins/roundPlugin.mjs +84 -1
  63. package/dist/plugins/seasonPlugin.cjs +47 -1
  64. package/dist/plugins/seasonPlugin.d.cts +17 -1
  65. package/dist/plugins/seasonPlugin.d.mts +17 -1
  66. package/dist/plugins/seasonPlugin.mjs +46 -1
  67. package/dist/plugins/timeZonePlugin.cjs +155 -1
  68. package/dist/plugins/timeZonePlugin.d.cts +17 -1
  69. package/dist/plugins/timeZonePlugin.d.mts +17 -1
  70. package/dist/plugins/timeZonePlugin.mjs +154 -1
  71. package/dist/plugins/zodiacPlugin.cjs +67 -1
  72. package/dist/plugins/zodiacPlugin.d.cts +17 -1
  73. package/dist/plugins/zodiacPlugin.d.mts +17 -1
  74. package/dist/plugins/zodiacPlugin.mjs +66 -1
  75. package/dist/primitives-CtuSNmV7.cjs +65 -0
  76. package/dist/primitives-dXzXlzJw.mjs +35 -0
  77. package/dist/seasons-B7kK88zq.cjs +434 -0
  78. package/dist/{seasons-CioTH5Dm.d.mts → seasons-B_kjFWIX.d.mts} +16 -0
  79. package/dist/{seasons-CsVeJ27s.d.cts → seasons-CpUn45n6.d.cts} +16 -0
  80. package/dist/seasons-Cq3ah3pV.mjs +368 -0
  81. package/dist/timezone-BNnHFgki.cjs +5625 -0
  82. package/dist/timezone-Db2CeL32.mjs +5589 -0
  83. package/dist/{types-B2fgrJ86.d.mts → types-Cb4gxrgJ.d.mts} +29 -15
  84. package/dist/{types-DPTQ_yLx.d.cts → types-CdmsXbU_.d.cts} +29 -15
  85. package/dist/types.cjs +16 -0
  86. package/dist/types.d.cts +18 -2
  87. package/dist/types.d.mts +18 -2
  88. package/dist/types.mjs +17 -1
  89. package/dist/utilities-BGX8dviZ.mjs +257 -0
  90. package/dist/utilities-BKtVo78T.mjs +59 -0
  91. package/dist/utilities-CpF3uys3.cjs +88 -0
  92. package/dist/utilities-D47SN9EZ.cjs +334 -0
  93. package/dist/utils.cjs +92 -1
  94. package/dist/utils.d.cts +20 -4
  95. package/dist/utils.d.mts +20 -4
  96. package/dist/utils.mjs +60 -1
  97. package/package.json +10 -4
  98. package/dist/basic-CKxaRSHQ.cjs +0 -1
  99. package/dist/basic-e46DaNAi.mjs +0 -1
  100. package/dist/convert-Bmp63ats.mjs +0 -1
  101. package/dist/convert-DrLrcgqz.cjs +0 -1
  102. package/dist/greet-BBsrvmkn.mjs +0 -1
  103. package/dist/greet-C-6mruI9.cjs +0 -1
  104. package/dist/helpers-DGzYnP81.cjs +0 -1
  105. package/dist/helpers-N1X_Rj_V.mjs +0 -1
  106. package/dist/non-primitives-B2EE6D6s.mjs +0 -1
  107. package/dist/non-primitives-Bu3a4WL4.cjs +0 -1
  108. package/dist/primitives-Cxss_JVF.mjs +0 -1
  109. package/dist/primitives-Db2FUp4e.cjs +0 -1
  110. package/dist/seasons-ChAIVphi.mjs +0 -1
  111. package/dist/seasons-oABOhHcX.cjs +0 -1
  112. package/dist/timezone-B10UItNO.mjs +0 -1
  113. package/dist/timezone-CWxbK_7I.cjs +0 -1
  114. package/dist/utilities-B8dOAQVD.cjs +0 -1
  115. package/dist/utilities-BJE06bms.mjs +0 -1
  116. package/dist/utilities-D2-p26DX.cjs +0 -1
  117. package/dist/utilities-DV_ohS37.mjs +0 -1
@@ -1 +1,106 @@
1
- import{s as e}from"../basic-e46DaNAi.mjs";const t=t=>{let{toNewDate:n}=t[e],r=(e,t,n)=>{let r=Object.entries(e),i={...e};if(!t&&!n)for(let[e,t]of r)t!==0&&(i[e]=t*-1);else if(t)for(let[e,t]of r)i[e]=Math.abs(t);return i};t.prototype.duration=function(e,t=!0){let i=this.toDate(),a=n(this,e),o=a>i,s=o?i:a,c=o?a:i,l=e=>c[`get${e}`]()-s[`get${e}`](),u=l(`FullYear`),d=l(`Month`),f=l(`Date`),p=l(`Hours`),m=l(`Minutes`),h=l(`Seconds`),g=l(`Milliseconds`);if(g<0&&(g+=1e3,h--),h<0&&(h+=60,m--),m<0&&(m+=60,p--),p<0&&(p+=24,f--),f<0){let e=new Date(c.getFullYear(),c.getMonth(),0);f+=e.getDate(),d--}return d<0&&(d+=12,u--),r({years:u,months:d,days:f,hours:p,minutes:m,seconds:h,milliseconds:g},t,o)},t.prototype.durationString=function(e){let{toTime:t,absolute:n=!0,maxUnits:r=7,separator:i=`, `,style:a=`full`,showZero:o=!1}=e??{},s=this.duration(t,n),c={years:`y`,months:`mo`,days:`d`,hours:`h`,minutes:`m`,seconds:`s`,milliseconds:`ms`},l=(e,t)=>a===`short`?`${t}${c[e]}`:`${t} ${Math.abs(t)===1?e.slice(0,-1):e}`,u=Object.entries(s).filter(([e,t])=>o||Math.abs(t)>0).slice(0,r).map(([e,t])=>l(e,t));return u.length?u.join(i):a===`short`?`0s`:`0 seconds`}};export{t as durationPlugin};
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { s as INTERNALS } from "../basic-DqKyujoj.mjs";
18
+
19
+ //#region src/plugins/durationPlugin.ts
20
+ /** * Plugin to inject `duration` related methods */
21
+ const durationPlugin = ($Chronos) => {
22
+ const { toNewDate } = $Chronos[INTERNALS];
23
+ /**
24
+ * @private Normalizes duration values based on sign and `absolute` flag.
25
+ * @param result The raw time breakdown to normalize.
26
+ * @param absolute If true, ensures all values are positive.
27
+ * @param isFuture Whether the duration was forward (true) or backward (false).
28
+ * @returns The normalized duration object.
29
+ */
30
+ const _normalizeDuration = (result, absolute, isFuture) => {
31
+ const entries = Object.entries(result);
32
+ const updated = { ...result };
33
+ if (!absolute && !isFuture) {
34
+ for (const [key, value] of entries) if (value !== 0) updated[key] = value * -1;
35
+ } else if (absolute) for (const [key, value] of entries) updated[key] = Math.abs(value);
36
+ return updated;
37
+ };
38
+ $Chronos.prototype.duration = function(toTime, absolute = true) {
39
+ const now = this.toDate();
40
+ const target = toNewDate(this, toTime);
41
+ const isFuture = target > now;
42
+ const from = isFuture ? now : target;
43
+ const to = isFuture ? target : now;
44
+ /** Get difference between `to` and `from` for specific unit */
45
+ const _getDiff = (suffix) => {
46
+ return to[`get${suffix}`]() - from[`get${suffix}`]();
47
+ };
48
+ let y = _getDiff("FullYear"), mo = _getDiff("Month"), d = _getDiff("Date"), h = _getDiff("Hours"), m = _getDiff("Minutes"), s = _getDiff("Seconds"), ms = _getDiff("Milliseconds");
49
+ if (ms < 0) {
50
+ ms += 1e3;
51
+ s--;
52
+ }
53
+ if (s < 0) {
54
+ s += 60;
55
+ m--;
56
+ }
57
+ if (m < 0) {
58
+ m += 60;
59
+ h--;
60
+ }
61
+ if (h < 0) {
62
+ h += 24;
63
+ d--;
64
+ }
65
+ if (d < 0) {
66
+ const prevMonth = new Date(to.getFullYear(), to.getMonth(), 0);
67
+ d += prevMonth.getDate();
68
+ mo--;
69
+ }
70
+ if (mo < 0) {
71
+ mo += 12;
72
+ y--;
73
+ }
74
+ return _normalizeDuration({
75
+ years: y,
76
+ months: mo,
77
+ days: d,
78
+ hours: h,
79
+ minutes: m,
80
+ seconds: s,
81
+ milliseconds: ms
82
+ }, absolute, isFuture);
83
+ };
84
+ $Chronos.prototype.durationString = function(options) {
85
+ const { toTime, absolute = true, maxUnits = 7, separator = ", ", style = "full", showZero = false } = options ?? {};
86
+ const duration = this.duration(toTime, absolute);
87
+ const units = {
88
+ years: "y",
89
+ months: "mo",
90
+ days: "d",
91
+ hours: "h",
92
+ minutes: "m",
93
+ seconds: "s",
94
+ milliseconds: "ms"
95
+ };
96
+ const _formatUnit = (unit, value) => {
97
+ if (style === "short") return `${value}${units[unit]}`;
98
+ return `${value} ${Math.abs(value) === 1 ? unit.slice(0, -1) : unit}`;
99
+ };
100
+ const parts = Object.entries(duration).filter(([_, value]) => showZero || Math.abs(value) > 0).slice(0, maxUnits).map(([unit, value]) => _formatUnit(unit, value));
101
+ return parts.length ? parts.join(separator) : style === "short" ? "0s" : "0 seconds";
102
+ };
103
+ };
104
+
105
+ //#endregion
106
+ export { durationPlugin };
@@ -1 +1,96 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../convert-DrLrcgqz.cjs`),n=n=>{let{toNewDate:r}=n[e.s];n.prototype.fromNow=function(e=`second`,n=!0,i){let a=r(this,i),o=this.toDate(),s=o>a,c=s?a:o,l=s?o:a,u=e=>l[`get${e}`]()-c[`get${e}`](),d=u(`FullYear`),f=u(`Month`),p=u(`Date`),m=u(`Hours`),h=u(`Minutes`),g=u(`Seconds`),_=u(`Milliseconds`);if(_<0&&(_+=1e3,g--),g<0&&(g+=60,h--),h<0&&(h+=60,m--),m<0&&(m+=24,p--),p<0){let e=new Date(l.getFullYear(),l.getMonth(),0);p+=e.getDate(),f--}f<0&&(f+=12,d--);let v=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],y=v.indexOf(e),b=[],x=(e,n)=>{b.push(t.t(e,n))},S=e=>y>=v.indexOf(e);d>0&&x(d,`year`),S(`month`)&&f>0&&x(f,`month`),S(`day`)&&p>0&&x(p,`day`),S(`hour`)&&m>0&&x(m,`hour`),S(`minute`)&&h>0&&x(h,`minute`),S(`second`)&&g>0&&x(g,`second`),S(`millisecond`)&&(_>0||b?.length===0)&&x(_,`millisecond`);let C=``,w=``;return n&&(s?C=`in `:w=` ago`),`${C}${b.length?b?.join(` `):`0 ${e}s`}${w}`}};exports.fromNowPlugin=n;
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_basic = require('../basic-DsQqC5nZ.cjs');
19
+ const require_convert = require('../convert-DbgntRVW.cjs');
20
+
21
+ //#region src/plugins/fromNowPlugin.ts
22
+ /** * Plugin to inject `fromNow` method */
23
+ const fromNowPlugin = ($Chronos) => {
24
+ const { toNewDate } = $Chronos[require_basic.INTERNALS];
25
+ $Chronos.prototype.fromNow = function(level = "second", wSP = true, time) {
26
+ const now = toNewDate(this, time);
27
+ const target = this.toDate();
28
+ const isFuture = target > now;
29
+ const from = isFuture ? now : target;
30
+ const to = isFuture ? target : now;
31
+ /** Get difference between `to` and `from` for specific unit */
32
+ const _getDiff = (suffix) => {
33
+ return to[`get${suffix}`]() - from[`get${suffix}`]();
34
+ };
35
+ let y = _getDiff("FullYear"), mo = _getDiff("Month"), d = _getDiff("Date"), h = _getDiff("Hours"), m = _getDiff("Minutes"), s = _getDiff("Seconds"), ms = _getDiff("Milliseconds");
36
+ if (ms < 0) {
37
+ ms += 1e3;
38
+ s--;
39
+ }
40
+ if (s < 0) {
41
+ s += 60;
42
+ m--;
43
+ }
44
+ if (m < 0) {
45
+ m += 60;
46
+ h--;
47
+ }
48
+ if (h < 0) {
49
+ h += 24;
50
+ d--;
51
+ }
52
+ if (d < 0) {
53
+ const prevMonth = new Date(to.getFullYear(), to.getMonth(), 0);
54
+ d += prevMonth.getDate();
55
+ mo--;
56
+ }
57
+ if (mo < 0) {
58
+ mo += 12;
59
+ y--;
60
+ }
61
+ const unitOrder = [
62
+ "year",
63
+ "month",
64
+ "day",
65
+ "hour",
66
+ "minute",
67
+ "second",
68
+ "millisecond"
69
+ ];
70
+ const lvlIdx = unitOrder.indexOf(level);
71
+ const parts = [];
72
+ /** Push value-unit string to `parts` array */
73
+ const _pushToParts = (value, unit) => {
74
+ parts.push(require_convert.formatUnitWithPlural(value, unit));
75
+ };
76
+ /** Check if a unit level is required */
77
+ const _isLevelRequired = (unit) => {
78
+ return lvlIdx >= unitOrder.indexOf(unit);
79
+ };
80
+ if (y > 0) _pushToParts(y, "year");
81
+ if (_isLevelRequired("month") && mo > 0) _pushToParts(mo, "month");
82
+ if (_isLevelRequired("day") && d > 0) _pushToParts(d, "day");
83
+ if (_isLevelRequired("hour") && h > 0) _pushToParts(h, "hour");
84
+ if (_isLevelRequired("minute") && m > 0) _pushToParts(m, "minute");
85
+ if (_isLevelRequired("second") && s > 0) _pushToParts(s, "second");
86
+ if (_isLevelRequired("millisecond") && (ms > 0 || parts?.length === 0)) _pushToParts(ms, "millisecond");
87
+ let prefix = "";
88
+ let suffix = "";
89
+ if (wSP) if (isFuture) prefix = "in ";
90
+ else suffix = " ago";
91
+ return `${prefix}${parts.length ? parts?.join(" ") : `0 ${level}s`}${suffix}`;
92
+ };
93
+ };
94
+
95
+ //#endregion
96
+ exports.fromNowPlugin = fromNowPlugin;
@@ -1,4 +1,20 @@
1
- import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-DPTQ_yLx.cjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-CdmsXbU_.cjs";
2
18
 
3
19
  //#region src/plugins/fromNowPlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1,4 +1,20 @@
1
- import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-B2fgrJ86.mjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-Cb4gxrgJ.mjs";
2
18
 
3
19
  //#region src/plugins/fromNowPlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1 +1,95 @@
1
- import{s as e}from"../basic-e46DaNAi.mjs";import{t}from"../convert-Bmp63ats.mjs";const n=n=>{let{toNewDate:r}=n[e];n.prototype.fromNow=function(e=`second`,n=!0,i){let a=r(this,i),o=this.toDate(),s=o>a,c=s?a:o,l=s?o:a,u=e=>l[`get${e}`]()-c[`get${e}`](),d=u(`FullYear`),f=u(`Month`),p=u(`Date`),m=u(`Hours`),h=u(`Minutes`),g=u(`Seconds`),_=u(`Milliseconds`);if(_<0&&(_+=1e3,g--),g<0&&(g+=60,h--),h<0&&(h+=60,m--),m<0&&(m+=24,p--),p<0){let e=new Date(l.getFullYear(),l.getMonth(),0);p+=e.getDate(),f--}f<0&&(f+=12,d--);let v=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],y=v.indexOf(e),b=[],x=(e,n)=>{b.push(t(e,n))},S=e=>y>=v.indexOf(e);d>0&&x(d,`year`),S(`month`)&&f>0&&x(f,`month`),S(`day`)&&p>0&&x(p,`day`),S(`hour`)&&m>0&&x(m,`hour`),S(`minute`)&&h>0&&x(h,`minute`),S(`second`)&&g>0&&x(g,`second`),S(`millisecond`)&&(_>0||b?.length===0)&&x(_,`millisecond`);let C=``,w=``;return n&&(s?C=`in `:w=` ago`),`${C}${b.length?b?.join(` `):`0 ${e}s`}${w}`}};export{n as fromNowPlugin};
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { s as INTERNALS } from "../basic-DqKyujoj.mjs";
18
+ import { t as formatUnitWithPlural } from "../convert-mMaI4YP0.mjs";
19
+
20
+ //#region src/plugins/fromNowPlugin.ts
21
+ /** * Plugin to inject `fromNow` method */
22
+ const fromNowPlugin = ($Chronos) => {
23
+ const { toNewDate } = $Chronos[INTERNALS];
24
+ $Chronos.prototype.fromNow = function(level = "second", wSP = true, time) {
25
+ const now = toNewDate(this, time);
26
+ const target = this.toDate();
27
+ const isFuture = target > now;
28
+ const from = isFuture ? now : target;
29
+ const to = isFuture ? target : now;
30
+ /** Get difference between `to` and `from` for specific unit */
31
+ const _getDiff = (suffix) => {
32
+ return to[`get${suffix}`]() - from[`get${suffix}`]();
33
+ };
34
+ let y = _getDiff("FullYear"), mo = _getDiff("Month"), d = _getDiff("Date"), h = _getDiff("Hours"), m = _getDiff("Minutes"), s = _getDiff("Seconds"), ms = _getDiff("Milliseconds");
35
+ if (ms < 0) {
36
+ ms += 1e3;
37
+ s--;
38
+ }
39
+ if (s < 0) {
40
+ s += 60;
41
+ m--;
42
+ }
43
+ if (m < 0) {
44
+ m += 60;
45
+ h--;
46
+ }
47
+ if (h < 0) {
48
+ h += 24;
49
+ d--;
50
+ }
51
+ if (d < 0) {
52
+ const prevMonth = new Date(to.getFullYear(), to.getMonth(), 0);
53
+ d += prevMonth.getDate();
54
+ mo--;
55
+ }
56
+ if (mo < 0) {
57
+ mo += 12;
58
+ y--;
59
+ }
60
+ const unitOrder = [
61
+ "year",
62
+ "month",
63
+ "day",
64
+ "hour",
65
+ "minute",
66
+ "second",
67
+ "millisecond"
68
+ ];
69
+ const lvlIdx = unitOrder.indexOf(level);
70
+ const parts = [];
71
+ /** Push value-unit string to `parts` array */
72
+ const _pushToParts = (value, unit) => {
73
+ parts.push(formatUnitWithPlural(value, unit));
74
+ };
75
+ /** Check if a unit level is required */
76
+ const _isLevelRequired = (unit) => {
77
+ return lvlIdx >= unitOrder.indexOf(unit);
78
+ };
79
+ if (y > 0) _pushToParts(y, "year");
80
+ if (_isLevelRequired("month") && mo > 0) _pushToParts(mo, "month");
81
+ if (_isLevelRequired("day") && d > 0) _pushToParts(d, "day");
82
+ if (_isLevelRequired("hour") && h > 0) _pushToParts(h, "hour");
83
+ if (_isLevelRequired("minute") && m > 0) _pushToParts(m, "minute");
84
+ if (_isLevelRequired("second") && s > 0) _pushToParts(s, "second");
85
+ if (_isLevelRequired("millisecond") && (ms > 0 || parts?.length === 0)) _pushToParts(ms, "millisecond");
86
+ let prefix = "";
87
+ let suffix = "";
88
+ if (wSP) if (isFuture) prefix = "in ";
89
+ else suffix = " ago";
90
+ return `${prefix}${parts.length ? parts?.join(" ") : `0 ${level}s`}${suffix}`;
91
+ };
92
+ };
93
+
94
+ //#endregion
95
+ export { fromNowPlugin };
@@ -1 +1,35 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../greet-C-6mruI9.cjs`),t=t=>{t.prototype.getGreeting=function(t){return e.t({currentTime:this.formatStrict(`HH:mm`),...t})},t.prototype.greet=function(e){return this.getGreeting(e)}};exports.greetingPlugin=t;
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_greet = require('../greet-hjVsd2dt.cjs');
19
+
20
+ //#region src/plugins/greetingPlugin.ts
21
+ /** * Plugin to inject `getGreeting`/`greet` method */
22
+ const greetingPlugin = ($Chronos) => {
23
+ $Chronos.prototype.getGreeting = function(configs) {
24
+ return require_greet.getGreeting({
25
+ currentTime: this.formatStrict("HH:mm"),
26
+ ...configs
27
+ });
28
+ };
29
+ $Chronos.prototype.greet = function(configs) {
30
+ return this.getGreeting(configs);
31
+ };
32
+ };
33
+
34
+ //#endregion
35
+ exports.greetingPlugin = greetingPlugin;
@@ -1,4 +1,20 @@
1
- import { C as $Chronos, dt as GreetingConfigs } from "../types-DPTQ_yLx.cjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos, dt as GreetingConfigs } from "../types-CdmsXbU_.cjs";
2
18
 
3
19
  //#region src/plugins/greetingPlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1,4 +1,20 @@
1
- import { C as $Chronos, dt as GreetingConfigs } from "../types-B2fgrJ86.mjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos, dt as GreetingConfigs } from "../types-Cb4gxrgJ.mjs";
2
18
 
3
19
  //#region src/plugins/greetingPlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1 +1,34 @@
1
- import{t as e}from"../greet-BBsrvmkn.mjs";const t=t=>{t.prototype.getGreeting=function(t){return e({currentTime:this.formatStrict(`HH:mm`),...t})},t.prototype.greet=function(e){return this.getGreeting(e)}};export{t as greetingPlugin};
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { t as getGreeting } from "../greet-D07t2_e6.mjs";
18
+
19
+ //#region src/plugins/greetingPlugin.ts
20
+ /** * Plugin to inject `getGreeting`/`greet` method */
21
+ const greetingPlugin = ($Chronos) => {
22
+ $Chronos.prototype.getGreeting = function(configs) {
23
+ return getGreeting({
24
+ currentTime: this.formatStrict("HH:mm"),
25
+ ...configs
26
+ });
27
+ };
28
+ $Chronos.prototype.greet = function(configs) {
29
+ return this.getGreeting(configs);
30
+ };
31
+ };
32
+
33
+ //#endregion
34
+ export { greetingPlugin };
@@ -1 +1,38 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../convert-DrLrcgqz.cjs`),t=t=>{let n=t.toLowerCase().replace(/[^a-z0-9]/g,``);return n===e.n(n)},n=e=>{e.prototype.isPalindromeDate=function(e=!1){let n=this.formatStrict(e?`YY-MM-DD`:`YYYY-MM-DD`),r=this.formatStrict(e?`YY-M-D`:`YYYY-M-D`);return t(n)||t(r)}};exports.palindromePlugin=n;
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_convert = require('../convert-DbgntRVW.cjs');
19
+
20
+ //#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/string/guards.js
21
+ const isPalindrome = (input) => {
22
+ const normalized = input.toLowerCase().replace(/[^a-z0-9]/g, "");
23
+ return normalized === require_convert.reverseString(normalized);
24
+ };
25
+
26
+ //#endregion
27
+ //#region src/plugins/palindromePlugin.ts
28
+ /** * Plugin to inject `isPalindromeDate` method */
29
+ const palindromePlugin = ($Chronos) => {
30
+ $Chronos.prototype.isPalindromeDate = function(shortYear = false) {
31
+ const padded = this.formatStrict(shortYear ? "YY-MM-DD" : "YYYY-MM-DD");
32
+ const normal = this.formatStrict(shortYear ? "YY-M-D" : "YYYY-M-D");
33
+ return isPalindrome(padded) || isPalindrome(normal);
34
+ };
35
+ };
36
+
37
+ //#endregion
38
+ exports.palindromePlugin = palindromePlugin;
@@ -1,4 +1,20 @@
1
- import { C as $Chronos } from "../types-DPTQ_yLx.cjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos } from "../types-CdmsXbU_.cjs";
2
18
 
3
19
  //#region src/plugins/palindromePlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1,4 +1,20 @@
1
- import { C as $Chronos } from "../types-B2fgrJ86.mjs";
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { C as $Chronos } from "../types-Cb4gxrgJ.mjs";
2
18
 
3
19
  //#region src/plugins/palindromePlugin.d.ts
4
20
  declare module 'chronos-date' {
@@ -1 +1,37 @@
1
- import{n as e}from"../convert-Bmp63ats.mjs";const t=t=>{let n=t.toLowerCase().replace(/[^a-z0-9]/g,``);return n===e(n)},n=e=>{e.prototype.isPalindromeDate=function(e=!1){let n=this.formatStrict(e?`YY-MM-DD`:`YYYY-MM-DD`),r=this.formatStrict(e?`YY-M-D`:`YYYY-M-D`);return t(n)||t(r)}};export{n as palindromePlugin};
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { n as reverseString } from "../convert-mMaI4YP0.mjs";
18
+
19
+ //#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/string/guards.js
20
+ const isPalindrome = (input) => {
21
+ const normalized = input.toLowerCase().replace(/[^a-z0-9]/g, "");
22
+ return normalized === reverseString(normalized);
23
+ };
24
+
25
+ //#endregion
26
+ //#region src/plugins/palindromePlugin.ts
27
+ /** * Plugin to inject `isPalindromeDate` method */
28
+ const palindromePlugin = ($Chronos) => {
29
+ $Chronos.prototype.isPalindromeDate = function(shortYear = false) {
30
+ const padded = this.formatStrict(shortYear ? "YY-MM-DD" : "YYYY-MM-DD");
31
+ const normal = this.formatStrict(shortYear ? "YY-M-D" : "YYYY-M-D");
32
+ return isPalindrome(padded) || isPalindrome(normal);
33
+ };
34
+ };
35
+
36
+ //#endregion
37
+ export { palindromePlugin };