chronos-date 1.0.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.
- package/LICENSE +201 -0
- package/README.md +31 -0
- package/dist/basic-CKxaRSHQ.cjs +1 -0
- package/dist/basic-e46DaNAi.mjs +1 -0
- package/dist/constants.cjs +1 -0
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +1 -0
- package/dist/convert-Bmp63ats.mjs +1 -0
- package/dist/convert-DrLrcgqz.cjs +1 -0
- package/dist/greet-BBsrvmkn.mjs +1 -0
- package/dist/greet-C-6mruI9.cjs +1 -0
- package/dist/guards.cjs +1 -0
- package/dist/guards.d.cts +71 -0
- package/dist/guards.d.mts +71 -0
- package/dist/guards.mjs +1 -0
- package/dist/helpers-DGzYnP81.cjs +1 -0
- package/dist/helpers-N1X_Rj_V.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/non-primitives-B2EE6D6s.mjs +1 -0
- package/dist/non-primitives-Bu3a4WL4.cjs +1 -0
- package/dist/plugins/banglaPlugin.cjs +1 -0
- package/dist/plugins/banglaPlugin.d.cts +225 -0
- package/dist/plugins/banglaPlugin.d.mts +225 -0
- package/dist/plugins/banglaPlugin.mjs +1 -0
- package/dist/plugins/businessPlugin.cjs +1 -0
- package/dist/plugins/businessPlugin.d.cts +446 -0
- package/dist/plugins/businessPlugin.d.mts +446 -0
- package/dist/plugins/businessPlugin.mjs +1 -0
- package/dist/plugins/dateRangePlugin.cjs +1 -0
- package/dist/plugins/dateRangePlugin.d.cts +71 -0
- package/dist/plugins/dateRangePlugin.d.mts +71 -0
- package/dist/plugins/dateRangePlugin.mjs +1 -0
- package/dist/plugins/dayPartPlugin.cjs +1 -0
- package/dist/plugins/dayPartPlugin.d.cts +45 -0
- package/dist/plugins/dayPartPlugin.d.mts +45 -0
- package/dist/plugins/dayPartPlugin.mjs +1 -0
- package/dist/plugins/durationPlugin.cjs +1 -0
- package/dist/plugins/durationPlugin.d.cts +30 -0
- package/dist/plugins/durationPlugin.d.mts +30 -0
- package/dist/plugins/durationPlugin.mjs +1 -0
- package/dist/plugins/fromNowPlugin.cjs +1 -0
- package/dist/plugins/fromNowPlugin.d.cts +24 -0
- package/dist/plugins/fromNowPlugin.d.mts +24 -0
- package/dist/plugins/fromNowPlugin.mjs +1 -0
- package/dist/plugins/greetingPlugin.cjs +1 -0
- package/dist/plugins/greetingPlugin.d.cts +29 -0
- package/dist/plugins/greetingPlugin.d.mts +29 -0
- package/dist/plugins/greetingPlugin.mjs +1 -0
- package/dist/plugins/palindromePlugin.cjs +1 -0
- package/dist/plugins/palindromePlugin.d.cts +38 -0
- package/dist/plugins/palindromePlugin.d.mts +38 -0
- package/dist/plugins/palindromePlugin.mjs +1 -0
- package/dist/plugins/relativeTimePlugin.cjs +1 -0
- package/dist/plugins/relativeTimePlugin.d.cts +82 -0
- package/dist/plugins/relativeTimePlugin.d.mts +82 -0
- package/dist/plugins/relativeTimePlugin.mjs +1 -0
- package/dist/plugins/roundPlugin.cjs +1 -0
- package/dist/plugins/roundPlugin.d.cts +29 -0
- package/dist/plugins/roundPlugin.d.mts +29 -0
- package/dist/plugins/roundPlugin.mjs +1 -0
- package/dist/plugins/seasonPlugin.cjs +1 -0
- package/dist/plugins/seasonPlugin.d.cts +26 -0
- package/dist/plugins/seasonPlugin.d.mts +26 -0
- package/dist/plugins/seasonPlugin.mjs +1 -0
- package/dist/plugins/timeZonePlugin.cjs +1 -0
- package/dist/plugins/timeZonePlugin.d.cts +88 -0
- package/dist/plugins/timeZonePlugin.d.mts +88 -0
- package/dist/plugins/timeZonePlugin.mjs +1 -0
- package/dist/plugins/zodiacPlugin.cjs +1 -0
- package/dist/plugins/zodiacPlugin.d.cts +41 -0
- package/dist/plugins/zodiacPlugin.d.mts +41 -0
- package/dist/plugins/zodiacPlugin.mjs +1 -0
- package/dist/primitives-Cxss_JVF.mjs +1 -0
- package/dist/primitives-Db2FUp4e.cjs +1 -0
- package/dist/seasons-ChAIVphi.mjs +1 -0
- package/dist/seasons-CioTH5Dm.d.mts +5285 -0
- package/dist/seasons-CsVeJ27s.d.cts +5285 -0
- package/dist/seasons-oABOhHcX.cjs +1 -0
- package/dist/timezone-B10UItNO.mjs +1 -0
- package/dist/timezone-CWxbK_7I.cjs +1 -0
- package/dist/types-B2fgrJ86.d.mts +2123 -0
- package/dist/types-DPTQ_yLx.d.cts +2123 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utilities-B8dOAQVD.cjs +1 -0
- package/dist/utilities-BJE06bms.mjs +1 -0
- package/dist/utilities-D2-p26DX.cjs +1 -0
- package/dist/utilities-DV_ohS37.mjs +1 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +188 -0
- package/dist/utils.d.mts +188 -0
- package/dist/utils.mjs +1 -0
- package/package.json +162 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { C as $Chronos, c as DayPart, l as DayPartConfig } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/dayPartPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the part of day (`'midnight', 'lateNight', 'night', 'morning', 'afternoon', 'evening'`) based on the current hour.
|
|
8
|
+
*
|
|
9
|
+
* *Supports both normal and wraparound (overnight) ranges.*
|
|
10
|
+
*
|
|
11
|
+
* @param config - Optional custom hour ranges for each part of day.
|
|
12
|
+
* Each range must be a tuple of strings as `[startHour, endHour]` in 24-hour format (e.g., `['06', '11']`).
|
|
13
|
+
* Supports wraparound ranges like `['22', '04']` that cross midnight.
|
|
14
|
+
*
|
|
15
|
+
* **Default Ranges:**
|
|
16
|
+
* - night: ['21', '23']
|
|
17
|
+
* - midnight: ['00', '01']
|
|
18
|
+
* - lateNight: ['02', '04']
|
|
19
|
+
* - morning: ['05', '11']
|
|
20
|
+
* - afternoon: ['12', '16']
|
|
21
|
+
* - evening: ['17', '20']
|
|
22
|
+
*
|
|
23
|
+
* @returns The current part of the day as a string.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* chronosInstance.getPartOfDay(); // e.g., 'morning'
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Example with custom ranges
|
|
30
|
+
* chronosInstance.getPartOfDay({
|
|
31
|
+
* night: ['22', '04'],
|
|
32
|
+
* morning: ['05', '11'],
|
|
33
|
+
* afternoon: ['12', '16'],
|
|
34
|
+
* evening: ['17', '21'],
|
|
35
|
+
* lateNight: ['01', '03'],
|
|
36
|
+
* midnight: ['00', '00'],
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
getPartOfDay(config?: DayPartConfig): DayPart;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** * Plugin to inject `getPartOfDay` method */
|
|
43
|
+
declare const dayPartPlugin: ($Chronos: $Chronos) => void;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { dayPartPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"../basic-e46DaNAi.mjs";import{n as t}from"../non-primitives-B2EE6D6s.mjs";const n=n=>{n.prototype.getPartOfDay=function(n){let r=this.hour,i={...e,...t(n)&&n};for(let[e,[t,n]]of Object.entries(i)){let i=Number(t),a=Number(n);if(i<=a){if(r>=i&&r<=a)return e}else if(r>=i||r<=a)return e}return`night`}};export{n as dayPartPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=t=>{let{toNewDate:n}=t[e.s],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`}};exports.durationPlugin=t;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, d as DurationOptions, g as TimeDuration } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/durationPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the full time duration breakdown between current input (start) and another time (to) as {@link TimeDuration} object.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This method calculates the elapsed time difference (excludes the end day), if you need an inclusive calendar-style difference (counting both start and end days), adjust one day manually before calling `duration()`.
|
|
10
|
+
*
|
|
11
|
+
* @param toTime The time to compare with. Defaults to `now`.
|
|
12
|
+
* @param absolute If true, returns all values as positive numbers. Defaults to `true`.
|
|
13
|
+
* @returns An object of time units: `years`, `months`, `days`, `hours`, `minutes`, `seconds`, `milliseconds` ({@link TimeDuration}).
|
|
14
|
+
*/
|
|
15
|
+
duration(toTime?: ChronosInput, absolute?: boolean): TimeDuration;
|
|
16
|
+
/**
|
|
17
|
+
* @instance Returns a human-readable formatted duration string between the current instance (start) and another time (to).
|
|
18
|
+
*
|
|
19
|
+
* @remarks This method calculates the elapsed time difference (excludes the end day), if you need an inclusive calendar-style difference (counting both start and end days), adjust one day manually before calling `durationString()`.
|
|
20
|
+
*
|
|
21
|
+
* @param options {@link DurationOptions} to format duration string, including the time to compare with.
|
|
22
|
+
* @returns A formatted duration string, e.g. `"2 hours, 5 minutes"` or `"2h 5m"`.
|
|
23
|
+
*/
|
|
24
|
+
durationString(options?: DurationOptions): string;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** * Plugin to inject `duration` related methods */
|
|
28
|
+
declare const durationPlugin: ($Chronos: $Chronos) => void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { durationPlugin };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, d as DurationOptions, g as TimeDuration } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/durationPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the full time duration breakdown between current input (start) and another time (to) as {@link TimeDuration} object.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This method calculates the elapsed time difference (excludes the end day), if you need an inclusive calendar-style difference (counting both start and end days), adjust one day manually before calling `duration()`.
|
|
10
|
+
*
|
|
11
|
+
* @param toTime The time to compare with. Defaults to `now`.
|
|
12
|
+
* @param absolute If true, returns all values as positive numbers. Defaults to `true`.
|
|
13
|
+
* @returns An object of time units: `years`, `months`, `days`, `hours`, `minutes`, `seconds`, `milliseconds` ({@link TimeDuration}).
|
|
14
|
+
*/
|
|
15
|
+
duration(toTime?: ChronosInput, absolute?: boolean): TimeDuration;
|
|
16
|
+
/**
|
|
17
|
+
* @instance Returns a human-readable formatted duration string between the current instance (start) and another time (to).
|
|
18
|
+
*
|
|
19
|
+
* @remarks This method calculates the elapsed time difference (excludes the end day), if you need an inclusive calendar-style difference (counting both start and end days), adjust one day manually before calling `durationString()`.
|
|
20
|
+
*
|
|
21
|
+
* @param options {@link DurationOptions} to format duration string, including the time to compare with.
|
|
22
|
+
* @returns A formatted duration string, e.g. `"2 hours, 5 minutes"` or `"2h 5m"`.
|
|
23
|
+
*/
|
|
24
|
+
durationString(options?: DurationOptions): string;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** * Plugin to inject `duration` related methods */
|
|
28
|
+
declare const durationPlugin: ($Chronos: $Chronos) => void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { durationPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/fromNowPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns full time difference from now (or a specified time) down to a given level.
|
|
8
|
+
*
|
|
9
|
+
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `second`.
|
|
10
|
+
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
11
|
+
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
12
|
+
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - This method calculates the **elapsed time difference** (exclusive of the end day), consistent with libraries like `Day.js` and `Luxon`.
|
|
16
|
+
* - If you need an *inclusive calendar-style* difference (counting both start and end days), adjust one day manually before calling `fromNow()`.
|
|
17
|
+
*/
|
|
18
|
+
fromNow(level?: FromNowUnit, withSuffixPrefix?: boolean, time?: ChronosInput): string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** * Plugin to inject `fromNow` method */
|
|
22
|
+
declare const fromNowPlugin: ($Chronos: $Chronos) => void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { fromNowPlugin };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, ut as FromNowUnit } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/fromNowPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns full time difference from now (or a specified time) down to a given level.
|
|
8
|
+
*
|
|
9
|
+
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `second`.
|
|
10
|
+
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
11
|
+
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
12
|
+
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - This method calculates the **elapsed time difference** (exclusive of the end day), consistent with libraries like `Day.js` and `Luxon`.
|
|
16
|
+
* - If you need an *inclusive calendar-style* difference (counting both start and end days), adjust one day manually before calling `fromNow()`.
|
|
17
|
+
*/
|
|
18
|
+
fromNow(level?: FromNowUnit, withSuffixPrefix?: boolean, time?: ChronosInput): string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** * Plugin to inject `fromNow` method */
|
|
22
|
+
declare const fromNowPlugin: ($Chronos: $Chronos) => void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { fromNowPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as $Chronos, dt as GreetingConfigs } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/greetingPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns a greeting message based on current instance of `Chronos` time or provided time in the `configs`.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This method internally uses {@link https://toolbox.nazmul-nhb.dev/docs/utilities/date/getGreeting getGreeting} function.
|
|
10
|
+
*
|
|
11
|
+
* @param configs - Configuration options for greeting times and messages.
|
|
12
|
+
* @returns The appropriate greeting message.
|
|
13
|
+
*/
|
|
14
|
+
getGreeting(configs?: GreetingConfigs): string;
|
|
15
|
+
/**
|
|
16
|
+
* @instance Returns a greeting message based on current instance of `Chronos` time or provided time in the `configs`.
|
|
17
|
+
*
|
|
18
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#getgreeting getGreeting} method.
|
|
19
|
+
*
|
|
20
|
+
* @param configs - Configuration options for greeting times and messages.
|
|
21
|
+
* @returns The appropriate greeting message.
|
|
22
|
+
*/
|
|
23
|
+
greet(configs?: GreetingConfigs): string;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** * Plugin to inject `getGreeting`/`greet` method */
|
|
27
|
+
declare const greetingPlugin: ($Chronos: $Chronos) => void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { greetingPlugin };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as $Chronos, dt as GreetingConfigs } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/greetingPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns a greeting message based on current instance of `Chronos` time or provided time in the `configs`.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This method internally uses {@link https://toolbox.nazmul-nhb.dev/docs/utilities/date/getGreeting getGreeting} function.
|
|
10
|
+
*
|
|
11
|
+
* @param configs - Configuration options for greeting times and messages.
|
|
12
|
+
* @returns The appropriate greeting message.
|
|
13
|
+
*/
|
|
14
|
+
getGreeting(configs?: GreetingConfigs): string;
|
|
15
|
+
/**
|
|
16
|
+
* @instance Returns a greeting message based on current instance of `Chronos` time or provided time in the `configs`.
|
|
17
|
+
*
|
|
18
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#getgreeting getGreeting} method.
|
|
19
|
+
*
|
|
20
|
+
* @param configs - Configuration options for greeting times and messages.
|
|
21
|
+
* @returns The appropriate greeting message.
|
|
22
|
+
*/
|
|
23
|
+
greet(configs?: GreetingConfigs): string;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** * Plugin to inject `getGreeting`/`greet` method */
|
|
27
|
+
declare const greetingPlugin: ($Chronos: $Chronos) => void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { greetingPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { C as $Chronos } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/palindromePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Checks if the current date is a palindrome in either padded or non-padded format.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A palindrome date reads the same forward and backward, excluding delimiters.
|
|
11
|
+
* This method checks both zero-padded (`MM-DD`) and non-padded (`M-D`) formats for flexibility.
|
|
12
|
+
*
|
|
13
|
+
* Examples of palindromes:
|
|
14
|
+
* - `'2020-02-02'` → `'20200202'` ✅
|
|
15
|
+
* - `'2112-11-12'` → `'21121112'` ❌
|
|
16
|
+
* - `'2011-01-11'` (from `'YY-M-D'`) → `'11111'` ✅
|
|
17
|
+
* - `'2011-01-11'` (from `'YYYY-M-D'`) → `'11111'` ❌
|
|
18
|
+
*
|
|
19
|
+
* @param shortYear - If `true`, uses `'YY-MM-DD'` and `'YY-M-D'` formats.
|
|
20
|
+
* If `false`, uses `'YYYY-MM-DD'` and `'YYYY-M-D'` formats.
|
|
21
|
+
* Defaults to `false`.
|
|
22
|
+
*
|
|
23
|
+
* @returns `true` if either padded or non-padded formatted date is a palindrome, otherwise `false`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* new Chronos('2020-02-02').isPalindromeDate(); // true
|
|
27
|
+
* new Chronos('2112-11-12').isPalindromeDate(); // false
|
|
28
|
+
* new Chronos('2011-1-11').isPalindromeDate(); // false (from '2011111')
|
|
29
|
+
* new Chronos('2011-1-11').isPalindromeDate(true); // true (from '11111')
|
|
30
|
+
* new Chronos('2024-04-11').isPalindromeDate(); // false
|
|
31
|
+
*/
|
|
32
|
+
isPalindromeDate(shortYear: boolean): boolean;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** * Plugin to inject `isPalindromeDate` method */
|
|
36
|
+
declare const palindromePlugin: ($Chronos: $Chronos) => void;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { palindromePlugin };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { C as $Chronos } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/palindromePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Checks if the current date is a palindrome in either padded or non-padded format.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A palindrome date reads the same forward and backward, excluding delimiters.
|
|
11
|
+
* This method checks both zero-padded (`MM-DD`) and non-padded (`M-D`) formats for flexibility.
|
|
12
|
+
*
|
|
13
|
+
* Examples of palindromes:
|
|
14
|
+
* - `'2020-02-02'` → `'20200202'` ✅
|
|
15
|
+
* - `'2112-11-12'` → `'21121112'` ❌
|
|
16
|
+
* - `'2011-01-11'` (from `'YY-M-D'`) → `'11111'` ✅
|
|
17
|
+
* - `'2011-01-11'` (from `'YYYY-M-D'`) → `'11111'` ❌
|
|
18
|
+
*
|
|
19
|
+
* @param shortYear - If `true`, uses `'YY-MM-DD'` and `'YY-M-D'` formats.
|
|
20
|
+
* If `false`, uses `'YYYY-MM-DD'` and `'YYYY-M-D'` formats.
|
|
21
|
+
* Defaults to `false`.
|
|
22
|
+
*
|
|
23
|
+
* @returns `true` if either padded or non-padded formatted date is a palindrome, otherwise `false`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* new Chronos('2020-02-02').isPalindromeDate(); // true
|
|
27
|
+
* new Chronos('2112-11-12').isPalindromeDate(); // false
|
|
28
|
+
* new Chronos('2011-1-11').isPalindromeDate(); // false (from '2011111')
|
|
29
|
+
* new Chronos('2011-1-11').isPalindromeDate(true); // true (from '11111')
|
|
30
|
+
* new Chronos('2024-04-11').isPalindromeDate(); // false
|
|
31
|
+
*/
|
|
32
|
+
isPalindromeDate(shortYear: boolean): boolean;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** * Plugin to inject `isPalindromeDate` method */
|
|
36
|
+
declare const palindromePlugin: ($Chronos: $Chronos) => void;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { palindromePlugin };
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=t=>{let{toNewDate:n}=t[e.s];t.prototype.getRelativeYear=function(e){let t=this.toDate(),r=n(this,e),i=t.getFullYear()-r.getFullYear();return(r.getMonth()<t.getMonth()||r.getMonth()===t.getMonth()&&r.getDate()<t.getDate())&&i--,i},t.prototype.getRelativeMonth=function(e){let t=this.toDate(),r=n(this,e),i=(t.getFullYear()-r.getFullYear())*12+(t.getMonth()-r.getMonth());return r.getDate()<t.getDate()&&i--,i},t.prototype.getRelativeWeek=function(e){let t=this.getRelativeDay(e);return Math.floor(t/7)},t.prototype.getRelativeDay=function(e){let t=n(this,e);t.setHours(0,0,0,0);let r=new Date(this.toDate());r.setHours(0,0,0,0);let i=r.getTime()-t.getTime();return Math.floor(i/(1e3*60*60*24))},t.prototype.getRelativeHour=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60*60))},t.prototype.getRelativeMinute=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60))},t.prototype.getRelativeSecond=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/1e3)},t.prototype.getRelativeMilliSecond=function(e){return this.getTimeStamp()-n(this,e).getTime()},t.prototype.compare=function(e=`minute`,t){switch(e){case`year`:return this.getRelativeYear(t);case`month`:return this.getRelativeMonth(t);case`day`:return this.getRelativeDay(t);case`week`:return this.getRelativeWeek(t);case`hour`:return this.getRelativeHour(t);case`minute`:return this.getRelativeMinute(t);case`second`:return this.getRelativeSecond(t);case`millisecond`:return this.getRelativeMilliSecond(t);default:throw RangeError(`Unsupported time unit: ${e}`)}},t.prototype.isToday=function(){return this.getRelativeDay()===0},t.prototype.isTomorrow=function(){return this.getRelativeDay()===1},t.prototype.isYesterday=function(){return this.getRelativeDay()===-1}};exports.relativeTimePlugin=t;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, Et as TimeUnit } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/relativeTimePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the number of full years between the input date and now.
|
|
8
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
9
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
10
|
+
*/
|
|
11
|
+
getRelativeYear(time?: ChronosInput): number;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the number of full months between the input date and now.
|
|
14
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
15
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
16
|
+
*/
|
|
17
|
+
getRelativeMonth(time?: ChronosInput): number;
|
|
18
|
+
/**
|
|
19
|
+
* @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
20
|
+
* @param date - The date to compare (Date object).
|
|
21
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
22
|
+
* @returns
|
|
23
|
+
* - `-1` if the date is yesterday.
|
|
24
|
+
* - `0` if the date is today.
|
|
25
|
+
* - `1` if the date is tomorrow.
|
|
26
|
+
* - Other positive or negative numbers for other relative days (e.g., `-2` for two days ago, `2` for two days ahead).
|
|
27
|
+
*/
|
|
28
|
+
getRelativeWeek(time?: ChronosInput): number;
|
|
29
|
+
/**
|
|
30
|
+
* @instance Returns the number of full hours between the input date and now.
|
|
31
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
32
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
33
|
+
*/
|
|
34
|
+
getRelativeDay(time?: ChronosInput): number;
|
|
35
|
+
/**
|
|
36
|
+
* @instance Determines how many full weeks apart the input date is from the `Chronos` instance.
|
|
37
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
38
|
+
* @returns Difference in weeks; negative if past, positive if future.
|
|
39
|
+
*/
|
|
40
|
+
getRelativeHour(time?: ChronosInput): number;
|
|
41
|
+
/**
|
|
42
|
+
* @instance Returns the number of full minutes between the input date and now.
|
|
43
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
44
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
45
|
+
*/
|
|
46
|
+
getRelativeMinute(time?: ChronosInput): number;
|
|
47
|
+
/**
|
|
48
|
+
* @instance Returns the number of full seconds between the input date and now.
|
|
49
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
50
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
51
|
+
*/
|
|
52
|
+
getRelativeSecond(time?: ChronosInput): number;
|
|
53
|
+
/**
|
|
54
|
+
* @instance Returns the number of milliseconds between the input date and now.
|
|
55
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
56
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
57
|
+
*/
|
|
58
|
+
getRelativeMilliSecond(time?: ChronosInput): number;
|
|
59
|
+
/**
|
|
60
|
+
* @instance Compares the stored date with now, returning the relative difference in the specified unit.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - Internally uses {@link getRelativeYear}, {@link getRelativeMonth}, {@link getRelativeWeek}, {@link getRelativeDay}, {@link getRelativeHour}, {@link getRelativeMinute}, {@link getRelativeSecond} and {@link getRelativeMilliSecond} and rounds the result.
|
|
64
|
+
* - To calculate accurate difference use {@link diff} method.
|
|
65
|
+
*
|
|
66
|
+
* @param unit The time unit to compare by. Defaults to `'minute'`.
|
|
67
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
68
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
69
|
+
*/
|
|
70
|
+
compare(unit?: TimeUnit, time?: ChronosInput): number;
|
|
71
|
+
/** @instance Checks if the current date is today. */
|
|
72
|
+
isToday(): boolean;
|
|
73
|
+
/** @instance Checks if the current date is tomorrow. */
|
|
74
|
+
isTomorrow(): boolean;
|
|
75
|
+
/** @instance Checks if the current date is yesterday. */
|
|
76
|
+
isYesterday(): boolean;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** * Plugin to inject `relative time` related methods */
|
|
80
|
+
declare const relativeTimePlugin: ($Chronos: $Chronos) => void;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { relativeTimePlugin };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { C as $Chronos, D as ChronosInput, Et as TimeUnit } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/relativeTimePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the number of full years between the input date and now.
|
|
8
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
9
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
10
|
+
*/
|
|
11
|
+
getRelativeYear(time?: ChronosInput): number;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the number of full months between the input date and now.
|
|
14
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
15
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
16
|
+
*/
|
|
17
|
+
getRelativeMonth(time?: ChronosInput): number;
|
|
18
|
+
/**
|
|
19
|
+
* @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
20
|
+
* @param date - The date to compare (Date object).
|
|
21
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
22
|
+
* @returns
|
|
23
|
+
* - `-1` if the date is yesterday.
|
|
24
|
+
* - `0` if the date is today.
|
|
25
|
+
* - `1` if the date is tomorrow.
|
|
26
|
+
* - Other positive or negative numbers for other relative days (e.g., `-2` for two days ago, `2` for two days ahead).
|
|
27
|
+
*/
|
|
28
|
+
getRelativeWeek(time?: ChronosInput): number;
|
|
29
|
+
/**
|
|
30
|
+
* @instance Returns the number of full hours between the input date and now.
|
|
31
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
32
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
33
|
+
*/
|
|
34
|
+
getRelativeDay(time?: ChronosInput): number;
|
|
35
|
+
/**
|
|
36
|
+
* @instance Determines how many full weeks apart the input date is from the `Chronos` instance.
|
|
37
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
38
|
+
* @returns Difference in weeks; negative if past, positive if future.
|
|
39
|
+
*/
|
|
40
|
+
getRelativeHour(time?: ChronosInput): number;
|
|
41
|
+
/**
|
|
42
|
+
* @instance Returns the number of full minutes between the input date and now.
|
|
43
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
44
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
45
|
+
*/
|
|
46
|
+
getRelativeMinute(time?: ChronosInput): number;
|
|
47
|
+
/**
|
|
48
|
+
* @instance Returns the number of full seconds between the input date and now.
|
|
49
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
50
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
51
|
+
*/
|
|
52
|
+
getRelativeSecond(time?: ChronosInput): number;
|
|
53
|
+
/**
|
|
54
|
+
* @instance Returns the number of milliseconds between the input date and now.
|
|
55
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
56
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
57
|
+
*/
|
|
58
|
+
getRelativeMilliSecond(time?: ChronosInput): number;
|
|
59
|
+
/**
|
|
60
|
+
* @instance Compares the stored date with now, returning the relative difference in the specified unit.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - Internally uses {@link getRelativeYear}, {@link getRelativeMonth}, {@link getRelativeWeek}, {@link getRelativeDay}, {@link getRelativeHour}, {@link getRelativeMinute}, {@link getRelativeSecond} and {@link getRelativeMilliSecond} and rounds the result.
|
|
64
|
+
* - To calculate accurate difference use {@link diff} method.
|
|
65
|
+
*
|
|
66
|
+
* @param unit The time unit to compare by. Defaults to `'minute'`.
|
|
67
|
+
* @param time Optional time to compare with the `Chronos` date/time. Defaults to current time.
|
|
68
|
+
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
|
|
69
|
+
*/
|
|
70
|
+
compare(unit?: TimeUnit, time?: ChronosInput): number;
|
|
71
|
+
/** @instance Checks if the current date is today. */
|
|
72
|
+
isToday(): boolean;
|
|
73
|
+
/** @instance Checks if the current date is tomorrow. */
|
|
74
|
+
isTomorrow(): boolean;
|
|
75
|
+
/** @instance Checks if the current date is yesterday. */
|
|
76
|
+
isYesterday(): boolean;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** * Plugin to inject `relative time` related methods */
|
|
80
|
+
declare const relativeTimePlugin: ($Chronos: $Chronos) => void;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { relativeTimePlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e}from"../basic-e46DaNAi.mjs";const t=t=>{let{toNewDate:n}=t[e];t.prototype.getRelativeYear=function(e){let t=this.toDate(),r=n(this,e),i=t.getFullYear()-r.getFullYear();return(r.getMonth()<t.getMonth()||r.getMonth()===t.getMonth()&&r.getDate()<t.getDate())&&i--,i},t.prototype.getRelativeMonth=function(e){let t=this.toDate(),r=n(this,e),i=(t.getFullYear()-r.getFullYear())*12+(t.getMonth()-r.getMonth());return r.getDate()<t.getDate()&&i--,i},t.prototype.getRelativeWeek=function(e){let t=this.getRelativeDay(e);return Math.floor(t/7)},t.prototype.getRelativeDay=function(e){let t=n(this,e);t.setHours(0,0,0,0);let r=new Date(this.toDate());r.setHours(0,0,0,0);let i=r.getTime()-t.getTime();return Math.floor(i/(1e3*60*60*24))},t.prototype.getRelativeHour=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60*60))},t.prototype.getRelativeMinute=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60))},t.prototype.getRelativeSecond=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/1e3)},t.prototype.getRelativeMilliSecond=function(e){return this.getTimeStamp()-n(this,e).getTime()},t.prototype.compare=function(e=`minute`,t){switch(e){case`year`:return this.getRelativeYear(t);case`month`:return this.getRelativeMonth(t);case`day`:return this.getRelativeDay(t);case`week`:return this.getRelativeWeek(t);case`hour`:return this.getRelativeHour(t);case`minute`:return this.getRelativeMinute(t);case`second`:return this.getRelativeSecond(t);case`millisecond`:return this.getRelativeMilliSecond(t);default:throw RangeError(`Unsupported time unit: ${e}`)}},t.prototype.isToday=function(){return this.getRelativeDay()===0},t.prototype.isTomorrow=function(){return this.getRelativeDay()===1},t.prototype.isYesterday=function(){return this.getRelativeDay()===-1}};export{t as relativeTimePlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../utilities-D2-p26DX.cjs`),n=n=>{let{internalDate:r,withOrigin:i,offset:a}=n[e.s];n.prototype.round=function(o,s=1){let c=new Date(r(this));switch(o){case`millisecond`:{let e=t.r(c.getMilliseconds(),s);c.setMilliseconds(e);break}case`second`:{let e=t.r(c.getSeconds()+c.getMilliseconds()/1e3,s);c.setSeconds(e,0);break}case`minute`:{let e=t.r(c.getMinutes()+c.getSeconds()/60+c.getMilliseconds()/6e4,s);c.setMinutes(e,0,0);break}case`hour`:{let e=t.r(c.getHours()+c.getMinutes()/60+c.getSeconds()/3600+c.getMilliseconds()/36e5,s);c.setHours(e,0,0,0);break}case`day`:{let n=t.r(c.getDate()+(c.getHours()/24+c.getMinutes()/1440+c.getSeconds()/86400+c.getMilliseconds()/e.u),s);c.setDate(n),c.setHours(0,0,0,0);break}case`week`:{let e=(c.getDay()+6)%7,t=new Date(c);t.setDate(t.getDate()-e),t.setHours(0,0,0,0);let r=new Date(t);r.setDate(r.getDate()+7);let a=Math.abs(c.getTime()-t.getTime());return i(new n(Math.abs(r.getTime()-c.getTime())<a?r:t),`round`)}case`month`:{let e=t.r(c.getMonth()+c.getDate()/this.lastDateOfMonth,s);c.setMonth(e,1),c.setHours(0,0,0,0);break}case`year`:{let n=Math.floor((c.getTime()-new Date(c.getFullYear(),0,1).getTime())/e.u),r=new Date(c.getFullYear(),1,29).getDate()===29?366:365,i=t.r(c.getFullYear()+n/r,s);c.setFullYear(i,0,1),c.setHours(0,0,0,0);break}default:return this}return i(new n(c),`round`,a(this),this.timeZoneName,this.timeZoneId,this.$tzTracker)}};exports.roundPlugin=n;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as $Chronos, Et as TimeUnit } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/roundPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Rounds the current date-time to the nearest specified unit and interval.
|
|
8
|
+
*
|
|
9
|
+
* - *Rounding is based on proximity to the start or end of the specified unit.*
|
|
10
|
+
* - *For example, rounding `2025-05-23` by 'day' returns either midnight of May 23 or May 24, depending on the time of day.*
|
|
11
|
+
*
|
|
12
|
+
* @param unit - The time unit to round to (`year`, `month`, `week`, `day`, `hour`, `minute`, `second`, `millisecond`).
|
|
13
|
+
* @param nearest - Optional granularity of rounding. (Defaults to `1`).
|
|
14
|
+
*
|
|
15
|
+
* @returns A new `Chronos` instance at the nearest rounded point in time. For wrong unit returns current instance.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* - Rounding for `'month'` is based on how far into the month the date is. If past the midpoint, it rounds to the next month.
|
|
19
|
+
* - Month indices are 0-based internally (January = 0), but the resulting date reflects the correct calendar month.
|
|
20
|
+
* - For `'week'` unit, rounding is performed by comparing proximity to the start and end of the ISO week (Monday to Sunday).
|
|
21
|
+
* - If the date is closer to the next Monday, it rounds forward; otherwise, it rounds back to the previous Monday.
|
|
22
|
+
*/
|
|
23
|
+
round(unit: TimeUnit, nearest?: number): Chronos;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** * Plugin to inject `round` method */
|
|
27
|
+
declare const roundPlugin: ($Chronos: $Chronos) => void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { roundPlugin };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as $Chronos, Et as TimeUnit } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/roundPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Rounds the current date-time to the nearest specified unit and interval.
|
|
8
|
+
*
|
|
9
|
+
* - *Rounding is based on proximity to the start or end of the specified unit.*
|
|
10
|
+
* - *For example, rounding `2025-05-23` by 'day' returns either midnight of May 23 or May 24, depending on the time of day.*
|
|
11
|
+
*
|
|
12
|
+
* @param unit - The time unit to round to (`year`, `month`, `week`, `day`, `hour`, `minute`, `second`, `millisecond`).
|
|
13
|
+
* @param nearest - Optional granularity of rounding. (Defaults to `1`).
|
|
14
|
+
*
|
|
15
|
+
* @returns A new `Chronos` instance at the nearest rounded point in time. For wrong unit returns current instance.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* - Rounding for `'month'` is based on how far into the month the date is. If past the midpoint, it rounds to the next month.
|
|
19
|
+
* - Month indices are 0-based internally (January = 0), but the resulting date reflects the correct calendar month.
|
|
20
|
+
* - For `'week'` unit, rounding is performed by comparing proximity to the start and end of the ISO week (Monday to Sunday).
|
|
21
|
+
* - If the date is closer to the next Monday, it rounds forward; otherwise, it rounds back to the previous Monday.
|
|
22
|
+
*/
|
|
23
|
+
round(unit: TimeUnit, nearest?: number): Chronos;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** * Plugin to inject `round` method */
|
|
27
|
+
declare const roundPlugin: ($Chronos: $Chronos) => void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { roundPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,u as t}from"../basic-e46DaNAi.mjs";import{r as n}from"../utilities-BJE06bms.mjs";const r=r=>{let{internalDate:i,withOrigin:a,offset:o}=r[e];r.prototype.round=function(e,s=1){let c=new Date(i(this));switch(e){case`millisecond`:{let e=n(c.getMilliseconds(),s);c.setMilliseconds(e);break}case`second`:{let e=n(c.getSeconds()+c.getMilliseconds()/1e3,s);c.setSeconds(e,0);break}case`minute`:{let e=n(c.getMinutes()+c.getSeconds()/60+c.getMilliseconds()/6e4,s);c.setMinutes(e,0,0);break}case`hour`:{let e=n(c.getHours()+c.getMinutes()/60+c.getSeconds()/3600+c.getMilliseconds()/36e5,s);c.setHours(e,0,0,0);break}case`day`:{let e=n(c.getDate()+(c.getHours()/24+c.getMinutes()/1440+c.getSeconds()/86400+c.getMilliseconds()/t),s);c.setDate(e),c.setHours(0,0,0,0);break}case`week`:{let e=(c.getDay()+6)%7,t=new Date(c);t.setDate(t.getDate()-e),t.setHours(0,0,0,0);let n=new Date(t);n.setDate(n.getDate()+7);let i=Math.abs(c.getTime()-t.getTime());return a(new r(Math.abs(n.getTime()-c.getTime())<i?n:t),`round`)}case`month`:{let e=n(c.getMonth()+c.getDate()/this.lastDateOfMonth,s);c.setMonth(e,1),c.setHours(0,0,0,0);break}case`year`:{let e=Math.floor((c.getTime()-new Date(c.getFullYear(),0,1).getTime())/t),r=new Date(c.getFullYear(),1,29).getDate()===29?366:365,i=n(c.getFullYear()+e/r,s);c.setFullYear(i,0,1),c.setHours(0,0,0,0);break}default:return this}return a(new r(c),`round`,o(this),this.timeZoneName,this.timeZoneId,this.$tzTracker)}};export{r as roundPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../seasons-oABOhHcX.cjs`),t=t=>{t.prototype.season=function(t){let{preset:n=`default`}=t??{},r=t?.seasons??e.u[n],i=this.format(`MM-DD`);for(let{name:e,boundary:t}of r)if(`startDate`in t&&`endDate`in t){let n=t.startDate,r=t.endDate;if(n<=r){if(i>=n&&i<=r)return e}else if(i>=n||i<=r)return e}else if(`startMonth`in t&&`endMonth`in t){let{startMonth:n,endMonth:r}=t;if(n<=r){if(this.month>=n&&this.month<=r)return e}else if(this.month>=n||this.month<=r)return e}return`Unknown`},t.prototype.getSeasonName=function(e){return this.season(e)}};exports.seasonPlugin=t;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { C as $Chronos, m as SeasonOptions } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/seasonPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the current season name based on optional season rules or presets.
|
|
8
|
+
* @param options Configuration with optional custom seasons or preset name.
|
|
9
|
+
* @returns The name of the season the current date falls under.
|
|
10
|
+
*/
|
|
11
|
+
season(options?: SeasonOptions): string;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the current season name based on optional season rules or presets.
|
|
14
|
+
*
|
|
15
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#season season} method.
|
|
16
|
+
*
|
|
17
|
+
* @param options Configuration with optional custom seasons or preset name.
|
|
18
|
+
* @returns The name of the season the current date falls under.
|
|
19
|
+
*/
|
|
20
|
+
getSeasonName(options?: SeasonOptions): string;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** * Plugin to inject `season`/`getSeasonName` method */
|
|
24
|
+
declare const seasonPlugin: ($Chronos: $Chronos) => void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { seasonPlugin };
|