nhb-toolbox 3.9.39 → 3.9.50
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/dist/colors/Color.d.ts +38 -24
- package/dist/colors/Color.d.ts.map +1 -1
- package/dist/colors/Color.js +19 -17
- package/dist/date/Chronos.d.ts +109 -30
- package/dist/date/Chronos.d.ts.map +1 -1
- package/dist/date/Chronos.js +64 -57
- package/dist/date/chronos-fn.d.ts +22 -32
- package/dist/date/chronos-fn.d.ts.map +1 -1
- package/dist/date/chronos-fn.js +59 -6
- package/dist/date/types.d.ts +85 -12
- package/dist/date/types.d.ts.map +1 -1
- package/dist/date/utils.js +1 -1
- package/package.json +1 -1
package/dist/colors/Color.d.ts
CHANGED
|
@@ -4,24 +4,47 @@ import type { AlphaColors, ColorType, Hex6, Hex8, HSL, HSLA, OpacityValue, RGB,
|
|
|
4
4
|
* * It has 1 instance method `applyOpacity()` to apply opacity to `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` color.
|
|
5
5
|
* * It has 6 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
|
|
6
6
|
*
|
|
7
|
-
* @property
|
|
8
|
-
* @property
|
|
9
|
-
* @property
|
|
10
|
-
* @property
|
|
11
|
-
* @property
|
|
12
|
-
* @property
|
|
7
|
+
* @property hex - The color in `Hex` format.
|
|
8
|
+
* @property hex8 - The color in `Hex8` format.
|
|
9
|
+
* @property rgb - The color in `RGB` format.
|
|
10
|
+
* @property rgba - The color in `RGBA` format.
|
|
11
|
+
* @property hsl - The color in `HSL` format.
|
|
12
|
+
* @property hsla - The color in `HSLA` format.
|
|
13
13
|
*/
|
|
14
14
|
export declare class Color {
|
|
15
|
+
#private;
|
|
15
16
|
hex: Hex6;
|
|
16
17
|
hex8: Hex8;
|
|
17
18
|
rgb: RGB;
|
|
18
19
|
rgba: RGBA;
|
|
19
20
|
hsl: HSL;
|
|
20
21
|
hsla: HSLA;
|
|
21
|
-
/** - Iterates over the color representations (Hex, RGB, HSL). */
|
|
22
|
-
[Symbol.iterator](): Generator<Hex6 | RGB | HSL | Hex8 | RGBA | HSLA, void, unknown>;
|
|
23
22
|
/**
|
|
24
|
-
* * Creates a new `Color` instance and automatically converts the
|
|
23
|
+
* * Creates a new `Color` instance with a random color and automatically converts the generated color to all other supported formats: `Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, and `HSLA`.
|
|
24
|
+
*
|
|
25
|
+
* @description
|
|
26
|
+
* The `Color` class generates a random color in six common color representations:
|
|
27
|
+
* - `Hex` (e.g., `#ff5733`)
|
|
28
|
+
* - `Hex8` (Hex with opacity, e.g., `#ff573380`)
|
|
29
|
+
* - `RGB` (e.g., `rgb(255, 87, 51)`)
|
|
30
|
+
* - `RGBA` (e.g., `rgba(255, 87, 51, 1)`)
|
|
31
|
+
* - `HSL` (e.g., `hsl(14, 100%, 60%)`)
|
|
32
|
+
* - `HSLA` (e.g., `hsla(14, 100%, 60%, 1)`)
|
|
33
|
+
*
|
|
34
|
+
* Additionally:
|
|
35
|
+
* - Use `.applyOpacity(opacity)` to modify or add opacity to the color.
|
|
36
|
+
* - Use static methods like `Color.isHex6(color)` to validate color strings.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Generate a random color
|
|
40
|
+
* const randomColor = new Color();
|
|
41
|
+
* console.log(randomColor.hex, randomColor.rgb, randomColor.hsl);
|
|
42
|
+
*
|
|
43
|
+
* @returns Instance of `Color`.
|
|
44
|
+
*/
|
|
45
|
+
constructor();
|
|
46
|
+
/**
|
|
47
|
+
* * Creates a new `Color` instance with the input color and automatically converts it to all other supported formats: `Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, and `HSLA`.
|
|
25
48
|
*
|
|
26
49
|
* @description
|
|
27
50
|
* The `Color` class allows seamless transformation between six common color representations:
|
|
@@ -33,13 +56,12 @@ export declare class Color {
|
|
|
33
56
|
* - `HSLA` (e.g., `hsla(14, 100%, 60%, 1)`)
|
|
34
57
|
*
|
|
35
58
|
* You can create a color from any of these formats, and the class will populate the rest.
|
|
36
|
-
* If no color is passed, a random color will be generated.
|
|
37
59
|
*
|
|
38
60
|
* Additionally:
|
|
39
61
|
* - Use `.applyOpacity(opacity)` to modify or add opacity to the color.
|
|
40
|
-
* - Use static methods like `Color.isHex6(color)` to validate color strings.
|
|
62
|
+
* - Use available 6 static methods like `Color.isHex6(color)` to validate color strings.
|
|
41
63
|
*
|
|
42
|
-
* @param toConvert -
|
|
64
|
+
* @param toConvert - A color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other formats (includes the current format).
|
|
43
65
|
*
|
|
44
66
|
* @example
|
|
45
67
|
* // Convert an existing Hex color to all other formats
|
|
@@ -56,12 +78,11 @@ export declare class Color {
|
|
|
56
78
|
* console.log(alphaColor.hex8); // '#FF000080'
|
|
57
79
|
* console.log(alphaColor.hsla); // 'hsla(0, 100%, 50%, 0.5)'
|
|
58
80
|
*
|
|
59
|
-
* @
|
|
60
|
-
* // Generate a random color
|
|
61
|
-
* const randomColor = new Color();
|
|
62
|
-
* console.log(randomColor.hex, randomColor.rgb, randomColor.hsl);
|
|
81
|
+
* @returns Instance of `Color`.
|
|
63
82
|
*/
|
|
64
|
-
constructor(toConvert
|
|
83
|
+
constructor(toConvert: ColorType);
|
|
84
|
+
/** - Iterates over the color representations (Hex, RGB, HSL). */
|
|
85
|
+
[Symbol.iterator](): Generator<Hex6 | RGB | HSL | Hex8 | RGBA | HSLA, void, unknown>;
|
|
65
86
|
/**
|
|
66
87
|
* * Applies or modifies the opacity of a color.
|
|
67
88
|
* - For solid colors (Hex6/RGB/HSL): Adds an alpha channel with the specified opacity
|
|
@@ -123,12 +144,5 @@ export declare class Color {
|
|
|
123
144
|
* @returns Boolean: `true` if it's an `HSLA` color, `false` if not.
|
|
124
145
|
*/
|
|
125
146
|
static isHSLA(color: string): color is HSLA;
|
|
126
|
-
/**
|
|
127
|
-
* @private Converts the given color to all other formats while preserving the original.
|
|
128
|
-
*
|
|
129
|
-
* @param color - The color to convert.
|
|
130
|
-
* @returns An object containing Hex, RGB, and HSL representations.
|
|
131
|
-
*/
|
|
132
|
-
private _convertColorToOthers;
|
|
133
147
|
}
|
|
134
148
|
//# sourceMappingURL=Color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/colors/Color.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,WAAW,EACX,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;GAWG;AACH,qBAAa,KAAK
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/colors/Color.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,WAAW,EACX,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;GAWG;AACH,qBAAa,KAAK;;IACV,GAAG,EAAE,IAAI,CAAC;IACV,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;gBACS,SAAS,EAAE,SAAS;IAwFhC,iEAAiE;IAChE,CAAC,MAAM,CAAC,QAAQ,CAAC;IASlB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW;IAkB9D;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAM3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;CAmC3C"}
|
package/dist/colors/Color.js
CHANGED
|
@@ -8,12 +8,12 @@ const { hex, rgb } = convertColorCode(hsl);
|
|
|
8
8
|
* * It has 1 instance method `applyOpacity()` to apply opacity to `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` color.
|
|
9
9
|
* * It has 6 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
|
|
10
10
|
*
|
|
11
|
-
* @property
|
|
12
|
-
* @property
|
|
13
|
-
* @property
|
|
14
|
-
* @property
|
|
15
|
-
* @property
|
|
16
|
-
* @property
|
|
11
|
+
* @property hex - The color in `Hex` format.
|
|
12
|
+
* @property hex8 - The color in `Hex8` format.
|
|
13
|
+
* @property rgb - The color in `RGB` format.
|
|
14
|
+
* @property rgba - The color in `RGBA` format.
|
|
15
|
+
* @property hsl - The color in `HSL` format.
|
|
16
|
+
* @property hsla - The color in `HSLA` format.
|
|
17
17
|
*/
|
|
18
18
|
export class Color {
|
|
19
19
|
hex;
|
|
@@ -22,15 +22,6 @@ export class Color {
|
|
|
22
22
|
rgba;
|
|
23
23
|
hsl;
|
|
24
24
|
hsla;
|
|
25
|
-
/** - Iterates over the color representations (Hex, RGB, HSL). */
|
|
26
|
-
*[Symbol.iterator]() {
|
|
27
|
-
yield this.hex;
|
|
28
|
-
yield this.hex8;
|
|
29
|
-
yield this.rgb;
|
|
30
|
-
yield this.rgba;
|
|
31
|
-
yield this.hsl;
|
|
32
|
-
yield this.hsla;
|
|
33
|
-
}
|
|
34
25
|
/**
|
|
35
26
|
* * Creates a new `Color` instance and automatically converts the input color to all other supported formats: `Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, and `HSLA`.
|
|
36
27
|
*
|
|
@@ -71,10 +62,12 @@ export class Color {
|
|
|
71
62
|
* // Generate a random color
|
|
72
63
|
* const randomColor = new Color();
|
|
73
64
|
* console.log(randomColor.hex, randomColor.rgb, randomColor.hsl);
|
|
65
|
+
*
|
|
66
|
+
* @returns Instance of `Color`.
|
|
74
67
|
*/
|
|
75
68
|
constructor(toConvert) {
|
|
76
69
|
if (toConvert) {
|
|
77
|
-
const colors = this
|
|
70
|
+
const colors = this.#convertColorToOthers(toConvert);
|
|
78
71
|
if ('hex8' in colors) {
|
|
79
72
|
// Extract alpha color values (Hex8, RGBA, HSLA)
|
|
80
73
|
const rgbaValues = _extractAlphaColorValues(colors.rgba);
|
|
@@ -112,6 +105,15 @@ export class Color {
|
|
|
112
105
|
this.hsla = `hsla(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%, 1)`;
|
|
113
106
|
}
|
|
114
107
|
}
|
|
108
|
+
/** - Iterates over the color representations (Hex, RGB, HSL). */
|
|
109
|
+
*[Symbol.iterator]() {
|
|
110
|
+
yield this.hex;
|
|
111
|
+
yield this.hex8;
|
|
112
|
+
yield this.rgb;
|
|
113
|
+
yield this.rgba;
|
|
114
|
+
yield this.hsl;
|
|
115
|
+
yield this.hsla;
|
|
116
|
+
}
|
|
115
117
|
/**
|
|
116
118
|
* * Applies or modifies the opacity of a color.
|
|
117
119
|
* - For solid colors (Hex6/RGB/HSL): Adds an alpha channel with the specified opacity
|
|
@@ -205,7 +207,7 @@ export class Color {
|
|
|
205
207
|
* @param color - The color to convert.
|
|
206
208
|
* @returns An object containing Hex, RGB, and HSL representations.
|
|
207
209
|
*/
|
|
208
|
-
|
|
210
|
+
#convertColorToOthers(color) {
|
|
209
211
|
if (Color.isHex6(color)) {
|
|
210
212
|
const { rgb, hsl } = convertColorCode(color);
|
|
211
213
|
return { hex: color, rgb, hsl };
|
package/dist/date/Chronos.d.ts
CHANGED
|
@@ -1,19 +1,96 @@
|
|
|
1
1
|
import type { LocaleCode } from '../number/types';
|
|
2
2
|
import { ORIGIN } from './constants';
|
|
3
|
-
import type { ChronosMethods, ChronosObject, FormatOptions, StrictFormat, TimeUnit, TimeZone, UTCOffSet } from './types';
|
|
3
|
+
import type { ChronosInput, ChronosMethods, ChronosObject, FormatOptions, StrictFormat, TimeUnit, TimeZone, UTCOffSet } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* * Creates a new immutable `Chronos` instance.
|
|
6
|
+
*
|
|
7
|
+
* @param value - A date value (`number`, `string`, `Date`, or `Chronos` object).
|
|
8
|
+
* - If a string is provided, it should be in a format that can be parsed by the Date constructor.
|
|
9
|
+
* - If a number is provided, it should be a timestamp (milliseconds since the Unix epoch).
|
|
10
|
+
* - If a Date object is provided, it will be used as is.
|
|
11
|
+
* - If a Chronos object is provided, it will be converted to a Date object.
|
|
12
|
+
*
|
|
13
|
+
* **It also accepts number values as following:**
|
|
14
|
+
* - **`year, month, date, hours, minutes, seconds, milliseconds`**: Individual components of a date-time to construct a `Chronos` instance.
|
|
15
|
+
* - **`year`**: A number representing the year. If the year is between 0 and 99, it will be assumed to be the year 1900 + the provided year.
|
|
16
|
+
* - **`month`**: A number between 1 and 12 representing the month (1 for January, 12 for December). It is adjusted internally to a 0-based index (0 for January, 11 for December).
|
|
17
|
+
* - **`date`**: A number between 1 and 31 representing the day of the month.
|
|
18
|
+
* - **`hours`**: A number between 0 and 23 representing the hour of the day.
|
|
19
|
+
* - **`minutes`**: A number between 0 and 59 representing the minutes past the hour.
|
|
20
|
+
* - **`seconds`**: A number between 0 and 59 representing the seconds past the minute.
|
|
21
|
+
* - **`milliseconds`**: A number between 0 and 999 representing the milliseconds past the second.
|
|
22
|
+
*
|
|
23
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
24
|
+
*/
|
|
4
25
|
export declare class Chronos {
|
|
5
26
|
#private;
|
|
6
27
|
[ORIGIN]?: ChronosMethods | 'root';
|
|
28
|
+
/**
|
|
29
|
+
* * Creates a new immutable `Chronos` instance.
|
|
30
|
+
*
|
|
31
|
+
* Accepts no arguments (defaults to now).
|
|
32
|
+
*
|
|
33
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
34
|
+
*/
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* * Creates a new immutable `Chronos` instance.
|
|
38
|
+
*
|
|
39
|
+
* @param value - A date value in `number`, it should be a timestamp (milliseconds since the Unix epoch).
|
|
40
|
+
*
|
|
41
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
42
|
+
*/
|
|
43
|
+
constructor(value: number);
|
|
44
|
+
/**
|
|
45
|
+
* * Creates a new immutable `Chronos` instance.
|
|
46
|
+
*
|
|
47
|
+
* @param value - A date value in `string`, it should be in a format that can be parsed by the `Date` constructor.
|
|
48
|
+
*
|
|
49
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
50
|
+
*/
|
|
51
|
+
constructor(value: string);
|
|
52
|
+
/**
|
|
53
|
+
* * Creates a new immutable `Chronos` instance.
|
|
54
|
+
*
|
|
55
|
+
* @param value - A date value as `Date` object, it will be used as is.
|
|
56
|
+
*
|
|
57
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
58
|
+
*/
|
|
59
|
+
constructor(value: Date);
|
|
60
|
+
/**
|
|
61
|
+
* * Creates a new immutable `Chronos` instance.
|
|
62
|
+
*
|
|
63
|
+
* @param value - A date value as `Chronos` object.
|
|
64
|
+
*
|
|
65
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
66
|
+
*/
|
|
67
|
+
constructor(value: Chronos);
|
|
68
|
+
/**
|
|
69
|
+
* * Creates a new immutable `Chronos` instance.
|
|
70
|
+
*
|
|
71
|
+
* @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
|
72
|
+
* @param month The month as a number between 1 and 12 (January to December).
|
|
73
|
+
* @param date The date as a number between 1 and 31.
|
|
74
|
+
* @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
|
75
|
+
* @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
|
|
76
|
+
* @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
|
|
77
|
+
* @param ms A number from 0 to 999 that specifies the milliseconds.
|
|
78
|
+
*
|
|
79
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
80
|
+
*/
|
|
81
|
+
constructor(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number);
|
|
7
82
|
/**
|
|
8
83
|
* * Creates a new immutable `Chronos` instance.
|
|
9
84
|
*
|
|
10
85
|
* @param value - A date value (`number`, `string`, `Date`, or `Chronos` object).
|
|
11
|
-
* - If a string is provided, it should be in a format that can be parsed by the Date constructor.
|
|
86
|
+
* - If a string is provided, it should be in a format that can be parsed by the `Date` constructor.
|
|
12
87
|
* - If a number is provided, it should be a timestamp (milliseconds since the Unix epoch).
|
|
13
88
|
* - If a Date object is provided, it will be used as is.
|
|
14
|
-
* - If a Chronos object is provided, it will be
|
|
89
|
+
* - If a Chronos object is provided, it will be used directly.
|
|
90
|
+
*
|
|
91
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
15
92
|
*/
|
|
16
|
-
constructor(value?:
|
|
93
|
+
constructor(value?: ChronosInput);
|
|
17
94
|
[Symbol.iterator](): IterableIterator<[string, number]>;
|
|
18
95
|
/**
|
|
19
96
|
* * Enables primitive coercion like `console.log`, `${chronos}`, etc.
|
|
@@ -47,6 +124,8 @@ export declare class Chronos {
|
|
|
47
124
|
get isoMonth(): number;
|
|
48
125
|
/** Gets the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
49
126
|
get unix(): number;
|
|
127
|
+
/** Gets the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
128
|
+
get timestamp(): number;
|
|
50
129
|
/** @public @instance Returns a debug-friendly string for `console.log` or `util.inspect`. */
|
|
51
130
|
inspect(): string;
|
|
52
131
|
/** @public @instance Clones and returns a new Chronos instance with the same date. */
|
|
@@ -75,7 +154,7 @@ export declare class Chronos {
|
|
|
75
154
|
getTimeStamp(): number;
|
|
76
155
|
/**
|
|
77
156
|
* @public @instance Returns the current date and time in a specified format in local time.
|
|
78
|
-
* @description Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
157
|
+
* @description Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
79
158
|
*
|
|
80
159
|
* @param options - Configure format string and whether to format using utc offset.
|
|
81
160
|
* @returns Formatted date string in desired format.
|
|
@@ -172,19 +251,19 @@ export declare class Chronos {
|
|
|
172
251
|
* @param other The other date to compare.
|
|
173
252
|
* @param unit The unit to compare.
|
|
174
253
|
*/
|
|
175
|
-
isSame(other:
|
|
254
|
+
isSame(other: ChronosInput, unit: TimeUnit): boolean;
|
|
176
255
|
/**
|
|
177
256
|
* @public @instance Checks if this date is before another date in a specific unit.
|
|
178
257
|
* @param other The other date to compare.
|
|
179
258
|
* @param unit The unit to compare.
|
|
180
259
|
*/
|
|
181
|
-
isBefore(other:
|
|
260
|
+
isBefore(other: ChronosInput, unit: TimeUnit): boolean;
|
|
182
261
|
/**
|
|
183
262
|
* @public @instance Checks if this date is after another date in a specific unit.
|
|
184
263
|
* @param other The other date to compare.
|
|
185
264
|
* @param unit The unit to compare.
|
|
186
265
|
*/
|
|
187
|
-
isAfter(other:
|
|
266
|
+
isAfter(other: ChronosInput, unit: TimeUnit): boolean;
|
|
188
267
|
/**
|
|
189
268
|
* @public @instance Checks if the current date is between the given start and end dates.
|
|
190
269
|
*
|
|
@@ -198,7 +277,7 @@ export declare class Chronos {
|
|
|
198
277
|
*
|
|
199
278
|
* @returns `true` if the current date is within the specified range based on the `inclusive` mode.
|
|
200
279
|
*/
|
|
201
|
-
isBetween(start:
|
|
280
|
+
isBetween(start: ChronosInput, end: ChronosInput, inclusive?: '[]' | '[)' | '(]' | '()'): boolean;
|
|
202
281
|
/** @public @instance Checks if currently in DST */
|
|
203
282
|
isDST(): boolean;
|
|
204
283
|
/**
|
|
@@ -209,19 +288,19 @@ export declare class Chronos {
|
|
|
209
288
|
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
210
289
|
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
211
290
|
*/
|
|
212
|
-
fromNow(level?: Exclude<TimeUnit, 'millisecond'>, withSuffixPrefix?: boolean, time?:
|
|
291
|
+
fromNow(level?: Exclude<TimeUnit, 'millisecond'>, withSuffixPrefix?: boolean, time?: ChronosInput): string;
|
|
213
292
|
/**
|
|
214
293
|
* @public @instance Returns the number of full years between the input date and now.
|
|
215
294
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
216
295
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
217
296
|
*/
|
|
218
|
-
getRelativeYear(time?:
|
|
297
|
+
getRelativeYear(time?: ChronosInput): number;
|
|
219
298
|
/**
|
|
220
299
|
* @public @instance Returns the number of full months between the input date and now.
|
|
221
300
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
222
301
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
223
302
|
*/
|
|
224
|
-
getRelativeMonth(time?:
|
|
303
|
+
getRelativeMonth(time?: ChronosInput): number;
|
|
225
304
|
/**
|
|
226
305
|
* @public @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
227
306
|
* @param date - The date to compare (Date object).
|
|
@@ -232,37 +311,37 @@ export declare class Chronos {
|
|
|
232
311
|
* - `1` if the date is tomorrow.
|
|
233
312
|
* - Other positive or negative numbers for other relative days (e.g., `-2` for two days ago, `2` for two days ahead).
|
|
234
313
|
*/
|
|
235
|
-
getRelativeDay(time?:
|
|
314
|
+
getRelativeDay(time?: ChronosInput): number;
|
|
236
315
|
/**
|
|
237
316
|
* @public @instance Determines how many full weeks apart the input date is from the `Chronos` instance.
|
|
238
317
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
239
318
|
* @returns Difference in weeks; negative if past, positive if future.
|
|
240
319
|
*/
|
|
241
|
-
getRelativeWeek(time?:
|
|
320
|
+
getRelativeWeek(time?: ChronosInput): number;
|
|
242
321
|
/**
|
|
243
322
|
* @public @instance Returns the number of full hours between the input date and now.
|
|
244
323
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
245
324
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
246
325
|
*/
|
|
247
|
-
getRelativeHour(time?:
|
|
326
|
+
getRelativeHour(time?: ChronosInput): number;
|
|
248
327
|
/**
|
|
249
328
|
* @public @instance Returns the number of full minutes between the input date and now.
|
|
250
329
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
251
330
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
252
331
|
*/
|
|
253
|
-
getRelativeMinute(time?:
|
|
332
|
+
getRelativeMinute(time?: ChronosInput): number;
|
|
254
333
|
/**
|
|
255
334
|
* @public @instance Returns the number of full seconds between the input date and now.
|
|
256
335
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
257
336
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
258
337
|
*/
|
|
259
|
-
getRelativeSecond(time?:
|
|
338
|
+
getRelativeSecond(time?: ChronosInput): number;
|
|
260
339
|
/**
|
|
261
340
|
* @public @instance Returns the number of milliseconds between the input date and now.
|
|
262
341
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
263
342
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
264
343
|
*/
|
|
265
|
-
getRelativeMilliSecond(time?:
|
|
344
|
+
getRelativeMilliSecond(time?: ChronosInput): number;
|
|
266
345
|
/**
|
|
267
346
|
* @public @instance Compares the stored date with now, returning the difference in the specified unit.
|
|
268
347
|
*
|
|
@@ -270,7 +349,7 @@ export declare class Chronos {
|
|
|
270
349
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
271
350
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
272
351
|
*/
|
|
273
|
-
compare(unit?: TimeUnit, time?:
|
|
352
|
+
compare(unit?: TimeUnit, time?: ChronosInput): number;
|
|
274
353
|
/**
|
|
275
354
|
* @public @instance Returns a new Chronos instance at the start of a given unit.
|
|
276
355
|
* @param unit The unit to reset (e.g., year, month, day).
|
|
@@ -309,12 +388,12 @@ export declare class Chronos {
|
|
|
309
388
|
* @param other The other date to compare.
|
|
310
389
|
* @param unit The unit in which to return the difference.
|
|
311
390
|
*/
|
|
312
|
-
diff(other:
|
|
391
|
+
diff(other: ChronosInput, unit: TimeUnit): number;
|
|
313
392
|
/**
|
|
314
393
|
* @public @instance Returns a human-readable relative calendar time like "Today at 3:00 PM"
|
|
315
394
|
* @param baseDate Optional base date to compare with.
|
|
316
395
|
*/
|
|
317
|
-
calendar(baseDate?:
|
|
396
|
+
calendar(baseDate?: ChronosInput): string;
|
|
318
397
|
/** @public @instance Returns a short human-readable string like "2h ago", "in 5m" */
|
|
319
398
|
fromNowShort(): string;
|
|
320
399
|
/**
|
|
@@ -348,7 +427,7 @@ export declare class Chronos {
|
|
|
348
427
|
toLocal(): Chronos;
|
|
349
428
|
/**
|
|
350
429
|
* @public @static Returns the current date and time in a specified format in local time.
|
|
351
|
-
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
430
|
+
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
352
431
|
* @param options - Configure format string and whether to format using utc offset.
|
|
353
432
|
* @returns Formatted date string in desired format.
|
|
354
433
|
*/
|
|
@@ -377,27 +456,27 @@ export declare class Chronos {
|
|
|
377
456
|
* // returns Chronos instance with the parsed date 2023-12-31T15:30:45
|
|
378
457
|
* ```
|
|
379
458
|
*
|
|
380
|
-
* @param
|
|
381
|
-
* @param
|
|
382
|
-
* @returns
|
|
383
|
-
* @throws
|
|
459
|
+
* @param dateStr - The date string to be parsed
|
|
460
|
+
* @param format - The format of the date string. Tokens like `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss` are used to specify the structure.
|
|
461
|
+
* @returns A new `Chronos` instance representing the parsed date.
|
|
462
|
+
* @throws `Error` If the date string does not match the format.
|
|
384
463
|
*/
|
|
385
464
|
static parse(dateStr: string, format: string): Chronos;
|
|
386
465
|
/**
|
|
387
466
|
* @public @static Creates UTC Chronos
|
|
388
467
|
* @param dateLike Date input to create utc time.
|
|
389
468
|
*/
|
|
390
|
-
static utc(dateLike:
|
|
469
|
+
static utc(dateLike: ChronosInput): Chronos;
|
|
391
470
|
/**
|
|
392
471
|
* @public @static Returns earliest Chronos
|
|
393
472
|
* @param dates Date inputs.
|
|
394
473
|
*/
|
|
395
|
-
static min(...dates:
|
|
474
|
+
static min(...dates: ChronosInput[]): Chronos;
|
|
396
475
|
/**
|
|
397
476
|
* @public @static Returns latest Chronos
|
|
398
477
|
* @param dates Date inputs.
|
|
399
478
|
*/
|
|
400
|
-
static max(...dates:
|
|
479
|
+
static max(...dates: ChronosInput[]): Chronos;
|
|
401
480
|
/**
|
|
402
481
|
* @public @static Checks if the year in the date string or year (from 0 - 9999) is a leap year.
|
|
403
482
|
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
@@ -413,7 +492,7 @@ export declare class Chronos {
|
|
|
413
492
|
* @param date - A `number` (year or Unix timestamp), `string`, `Date`, or `Chronos` instance representing a date.
|
|
414
493
|
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
415
494
|
*/
|
|
416
|
-
static isLeapYear(date:
|
|
495
|
+
static isLeapYear(date: ChronosInput): boolean;
|
|
417
496
|
/**
|
|
418
497
|
* @public @static Checks if the given value is a valid `Date` object.
|
|
419
498
|
* - A value is considered valid if it is an instance of the built-in `Date` class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAGN,MAAM,EAIN,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEX,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB,qBAAa,OAAO;;IAGnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC
|
|
1
|
+
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAGN,MAAM,EAIN,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;;IAGnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;;IAGH;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE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AE,OAAO,GAAG,KAAK,IAAI,MAAM;IAIpD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;CAGvD"}
|
package/dist/date/Chronos.js
CHANGED
|
@@ -4,6 +4,27 @@ import { formatUnitWithPlural } from '../string/convert';
|
|
|
4
4
|
import { DAYS, MONTHS, ORIGIN, sortedFormats, TIME_ZONE_LABELS, TIME_ZONES, } from './constants';
|
|
5
5
|
import { isLeapYear, isValidUTCOffSet } from './guards';
|
|
6
6
|
import { extractMinutesFromUTC, formatUTCOffset } from './utils';
|
|
7
|
+
/**
|
|
8
|
+
* * Creates a new immutable `Chronos` instance.
|
|
9
|
+
*
|
|
10
|
+
* @param value - A date value (`number`, `string`, `Date`, or `Chronos` object).
|
|
11
|
+
* - If a string is provided, it should be in a format that can be parsed by the Date constructor.
|
|
12
|
+
* - If a number is provided, it should be a timestamp (milliseconds since the Unix epoch).
|
|
13
|
+
* - If a Date object is provided, it will be used as is.
|
|
14
|
+
* - If a Chronos object is provided, it will be converted to a Date object.
|
|
15
|
+
*
|
|
16
|
+
* **It also accepts number values as following:**
|
|
17
|
+
* - **`year, month, date, hours, minutes, seconds, milliseconds`**: Individual components of a date-time to construct a `Chronos` instance.
|
|
18
|
+
* - **`year`**: A number representing the year. If the year is between 0 and 99, it will be assumed to be the year 1900 + the provided year.
|
|
19
|
+
* - **`month`**: A number between 1 and 12 representing the month (1 for January, 12 for December). It is adjusted internally to a 0-based index (0 for January, 11 for December).
|
|
20
|
+
* - **`date`**: A number between 1 and 31 representing the day of the month.
|
|
21
|
+
* - **`hours`**: A number between 0 and 23 representing the hour of the day.
|
|
22
|
+
* - **`minutes`**: A number between 0 and 59 representing the minutes past the hour.
|
|
23
|
+
* - **`seconds`**: A number between 0 and 59 representing the seconds past the minute.
|
|
24
|
+
* - **`milliseconds`**: A number between 0 and 999 representing the milliseconds past the second.
|
|
25
|
+
*
|
|
26
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
27
|
+
*/
|
|
7
28
|
export class Chronos {
|
|
8
29
|
#date;
|
|
9
30
|
#offset;
|
|
@@ -11,15 +32,25 @@ export class Chronos {
|
|
|
11
32
|
/**
|
|
12
33
|
* * Creates a new immutable `Chronos` instance.
|
|
13
34
|
*
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
35
|
+
* @param valueOrYear The value in number, string, Date or Chronos format or the full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
|
36
|
+
* @param month The month as a number between 1 and 12 (January to December).
|
|
37
|
+
* @param date The date as a number between 1 and 31.
|
|
38
|
+
* @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
|
39
|
+
* @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
|
|
40
|
+
* @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
|
|
41
|
+
* @param ms A number from 0 to 999 that specifies the milliseconds.
|
|
42
|
+
*
|
|
43
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
19
44
|
*/
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
constructor(valueOrYear, month, date, hours, minutes, seconds, ms) {
|
|
46
|
+
let newDate;
|
|
47
|
+
if (typeof valueOrYear === 'number' && typeof month === 'number') {
|
|
48
|
+
newDate = new Date(valueOrYear, month - 1, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
newDate = this.#toNewDate(valueOrYear);
|
|
52
|
+
}
|
|
53
|
+
this.#date = newDate;
|
|
23
54
|
this[ORIGIN] = 'root';
|
|
24
55
|
this.#offset = `UTC${this.getUTCOffset()}`;
|
|
25
56
|
}
|
|
@@ -86,20 +117,6 @@ export class Chronos {
|
|
|
86
117
|
return this.#toLocalISOString();
|
|
87
118
|
}
|
|
88
119
|
}
|
|
89
|
-
/**
|
|
90
|
-
* @private @instance Method to tag origin of the `Chronos` instance.
|
|
91
|
-
*
|
|
92
|
-
* @param origin Origin of the instance, the method name from where it was created.
|
|
93
|
-
* @param offset Optional UTC offset in `UTC+12:00` format.
|
|
94
|
-
* @returns The `Chronos` instance with the specified origin.
|
|
95
|
-
*/
|
|
96
|
-
#withOrigin(origin, offset) {
|
|
97
|
-
const instance = new Chronos(this.#date);
|
|
98
|
-
instance[ORIGIN] = origin;
|
|
99
|
-
if (offset)
|
|
100
|
-
instance.#offset = offset;
|
|
101
|
-
return instance;
|
|
102
|
-
}
|
|
103
120
|
/**
|
|
104
121
|
* @private @instance Method to create native `Date` instance from date-like data types.
|
|
105
122
|
* @param value The value to convert into `Date`.
|
|
@@ -115,6 +132,20 @@ export class Chronos {
|
|
|
115
132
|
}
|
|
116
133
|
return date;
|
|
117
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* @private @instance Method to tag origin of the `Chronos` instance.
|
|
137
|
+
*
|
|
138
|
+
* @param origin Origin of the instance, the method name from where it was created.
|
|
139
|
+
* @param offset Optional UTC offset in `UTC+12:00` format.
|
|
140
|
+
* @returns The `Chronos` instance with the specified origin.
|
|
141
|
+
*/
|
|
142
|
+
#withOrigin(origin, offset) {
|
|
143
|
+
const instance = new Chronos(this.#date);
|
|
144
|
+
instance[ORIGIN] = origin;
|
|
145
|
+
if (offset)
|
|
146
|
+
instance.#offset = offset;
|
|
147
|
+
return instance;
|
|
148
|
+
}
|
|
118
149
|
/**
|
|
119
150
|
* @private @instance Formats the current `Chronos` date using the specified template.
|
|
120
151
|
*
|
|
@@ -237,6 +268,10 @@ export class Chronos {
|
|
|
237
268
|
get unix() {
|
|
238
269
|
return this.#date.getTime();
|
|
239
270
|
}
|
|
271
|
+
/** Gets the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
272
|
+
get timestamp() {
|
|
273
|
+
return this.#date.getTime();
|
|
274
|
+
}
|
|
240
275
|
/** @public @instance Returns a debug-friendly string for `console.log` or `util.inspect`. */
|
|
241
276
|
inspect() {
|
|
242
277
|
return `[Chronos ${this.toLocalISOString()}]`;
|
|
@@ -328,7 +363,7 @@ export class Chronos {
|
|
|
328
363
|
}
|
|
329
364
|
/**
|
|
330
365
|
* @public @instance Returns the current date and time in a specified format in local time.
|
|
331
|
-
* @description Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
366
|
+
* @description Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
332
367
|
*
|
|
333
368
|
* @param options - Configure format string and whether to format using utc offset.
|
|
334
369
|
* @returns Formatted date string in desired format.
|
|
@@ -1021,25 +1056,6 @@ export class Chronos {
|
|
|
1021
1056
|
d.setDate(weekStart.getDate());
|
|
1022
1057
|
return new Chronos(d).#withOrigin('setWeek');
|
|
1023
1058
|
}
|
|
1024
|
-
// /**
|
|
1025
|
-
// * @public @instance Sets the date to the Monday of the specified ISO week number and year.
|
|
1026
|
-
// * @param week ISO week number (1–53)
|
|
1027
|
-
// * @param isoYear Optional ISO week year. Defaults to the current ISO week year.
|
|
1028
|
-
// * @returns New Chronos instance set to the start of the specified ISO week.
|
|
1029
|
-
// */
|
|
1030
|
-
// setISOWeek(week: number, isoYear?: number): Chronos {
|
|
1031
|
-
// // ❗ Use calendar year instead of ISO week year unless explicitly provided
|
|
1032
|
-
// const targetISOYear = isoYear ?? this.#date.getFullYear();
|
|
1033
|
-
// const jan4 = new Date(Date.UTC(targetISOYear, 0, 4));
|
|
1034
|
-
// const dayOfWeek = jan4.getUTCDay();
|
|
1035
|
-
// const offset = (dayOfWeek + 6) % 7;
|
|
1036
|
-
// const firstISOWeekStart = new Date(jan4);
|
|
1037
|
-
// firstISOWeekStart.setUTCDate(jan4.getUTCDate() - offset);
|
|
1038
|
-
// firstISOWeekStart.setUTCDate(
|
|
1039
|
-
// firstISOWeekStart.getUTCDate() + (week - 1) * 7,
|
|
1040
|
-
// );
|
|
1041
|
-
// return new Chronos(firstISOWeekStart).#withOrigin('setISOWeek');
|
|
1042
|
-
// }
|
|
1043
1059
|
/**
|
|
1044
1060
|
* @public @instance Calculates the ISO week number of the year.
|
|
1045
1061
|
* @returns Week number (1-53).
|
|
@@ -1058,15 +1074,6 @@ export class Chronos {
|
|
|
1058
1074
|
const d = this.startOf('week').add(3, 'day'); // Thursday of current ISO week
|
|
1059
1075
|
return d.year;
|
|
1060
1076
|
}
|
|
1061
|
-
// /**
|
|
1062
|
-
// * @private @instance Gets the ISO week-numbering year.
|
|
1063
|
-
// * @returns The ISO year (can differ from calendar year).
|
|
1064
|
-
// */
|
|
1065
|
-
// getISOWeekYear(): number {
|
|
1066
|
-
// const date = new Date(this.#date);
|
|
1067
|
-
// date.setDate(date.getDate() + 4 - (date.getDay() || 7)); // Thursday of the week
|
|
1068
|
-
// return date.getFullYear();
|
|
1069
|
-
// }
|
|
1070
1077
|
/** @public @instance Returns day of year (1 - 366) */
|
|
1071
1078
|
getDayOfYear() {
|
|
1072
1079
|
const start = new Date(this.year, 0, 1);
|
|
@@ -1106,7 +1113,7 @@ export class Chronos {
|
|
|
1106
1113
|
}
|
|
1107
1114
|
/**
|
|
1108
1115
|
* @public @static Returns the current date and time in a specified format in local time.
|
|
1109
|
-
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
1116
|
+
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
1110
1117
|
* @param options - Configure format string and whether to format using utc offset.
|
|
1111
1118
|
* @returns Formatted date string in desired format.
|
|
1112
1119
|
*/
|
|
@@ -1141,15 +1148,15 @@ export class Chronos {
|
|
|
1141
1148
|
* // returns Chronos instance with the parsed date 2023-12-31T15:30:45
|
|
1142
1149
|
* ```
|
|
1143
1150
|
*
|
|
1144
|
-
* @param
|
|
1145
|
-
* @param
|
|
1146
|
-
* @returns
|
|
1147
|
-
* @throws
|
|
1151
|
+
* @param dateStr - The date string to be parsed
|
|
1152
|
+
* @param format - The format of the date string. Tokens like `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss` are used to specify the structure.
|
|
1153
|
+
* @returns A new `Chronos` instance representing the parsed date.
|
|
1154
|
+
* @throws `Error` If the date string does not match the format.
|
|
1148
1155
|
*/
|
|
1149
1156
|
static parse(dateStr, format) {
|
|
1150
1157
|
const formatMap = {
|
|
1151
1158
|
YYYY: 'year',
|
|
1152
|
-
YY: 'year',
|
|
1159
|
+
YY: 'year',
|
|
1153
1160
|
MM: 'month',
|
|
1154
1161
|
DD: 'date',
|
|
1155
1162
|
HH: 'hour',
|
|
@@ -1,44 +1,34 @@
|
|
|
1
1
|
import type { ChronosStatics } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* The following types of input are supported:
|
|
8
|
-
*
|
|
9
|
-
* - **`string`**: A string representing a date, which can be parsed by the JavaScript `Date` constructor.
|
|
10
|
-
* Example: `"2023-12-31"`.
|
|
11
|
-
* - **`number`**: A timestamp representing the number of milliseconds since the Unix epoch.
|
|
12
|
-
* Example: `1672531199000`.
|
|
13
|
-
* - **`Date`**: A JavaScript `Date` object.
|
|
14
|
-
* - **`Chronos`**: A `Chronos` instance created by the same constructor.
|
|
15
|
-
*
|
|
16
|
-
* This function also allows you to access static methods from the `Chronos` class, as it copies all static methods from `Chronos` to the `chronos` function itself.
|
|
17
|
-
* Therefore, static methods can be called either through the `Chronos` class directly or through the `chronos` function.
|
|
3
|
+
* @static
|
|
4
|
+
* @remarks
|
|
5
|
+
* Static methods from the `Chronos` class are copied over to the `chronos` function.
|
|
6
|
+
* Therefore, you can access static methods from `Chronos` both through the `Chronos` class and the `chronos` function.
|
|
18
7
|
*
|
|
19
|
-
* @example
|
|
20
8
|
* Example usage:
|
|
21
|
-
*
|
|
22
9
|
* ```ts
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* const sameInstanceClass = Chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
10
|
+
* chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
11
|
+
* // Or
|
|
12
|
+
* Chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
27
13
|
* ```
|
|
28
14
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
15
|
+
* *No need to call `chronos` for accessing the static methods. Simply call them.*
|
|
16
|
+
*
|
|
17
|
+
* **Available Static Methods:**
|
|
31
18
|
*
|
|
32
|
-
* @static
|
|
33
|
-
* @remarks
|
|
34
|
-
* Static methods can be accessed from both the `Chronos` class and the `chronos` function.
|
|
35
|
-
* Static methods from the `Chronos` class are copied over to the `chronos` function, so you can call them like:
|
|
36
19
|
* ```ts
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
20
|
+
* today(options?: FormatOptions): string
|
|
21
|
+
* now(): number
|
|
22
|
+
* parse(dateStr: string, format: string): Chronos
|
|
23
|
+
* utc(dateLike: ChronosInput): Chronos
|
|
24
|
+
* min(...dates: (ChronosInput)[]): Chronos
|
|
25
|
+
* max(...dates: (ChronosInput)[]): Chronos
|
|
26
|
+
* isLeapYear(date: ChronosInput): boolean
|
|
27
|
+
* isValidDate(value: unknown): boolean
|
|
28
|
+
* isDateString(value: unknown): boolean
|
|
29
|
+
* isValidChronos(value: unknown): boolean
|
|
40
30
|
* ```
|
|
41
31
|
*/
|
|
42
|
-
declare const
|
|
43
|
-
export { chronos };
|
|
32
|
+
declare const typedChronos: ChronosStatics;
|
|
33
|
+
export { typedChronos as chronos };
|
|
44
34
|
//# sourceMappingURL=chronos-fn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chronos-fn.d.ts","sourceRoot":"","sources":["../../src/date/chronos-fn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"chronos-fn.d.ts","sourceRoot":"","sources":["../../src/date/chronos-fn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAqF5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,QAAA,MAAM,YAAY,EAAc,cAAc,CAAC;AAsB/C,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/date/chronos-fn.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chronos } from '..';
|
|
2
2
|
/**
|
|
3
|
-
* * Converts a date into a Chronos object and access to all `Chronos` methods.
|
|
3
|
+
* * Converts a date into a Chronos object and access to all `Chronos` methods and properties.
|
|
4
4
|
*
|
|
5
5
|
* @description
|
|
6
6
|
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
@@ -12,6 +12,14 @@ import { Chronos } from '..';
|
|
|
12
12
|
* Example: `1672531199000`.
|
|
13
13
|
* - **`Date`**: A JavaScript `Date` object.
|
|
14
14
|
* - **`Chronos`**: A `Chronos` instance created by the same constructor.
|
|
15
|
+
* - **`year, month, date, hours, minutes, seconds, milliseconds`**: Individual components of a date-time to construct a `Chronos` instance.
|
|
16
|
+
* - **`year`**: A number representing the year. If the year is between 0 and 99, it will be assumed to be the year 1900 + the provided year.
|
|
17
|
+
* - **`month`**: A number between 1 and 12 representing the month (1 for January, 12 for December). It is adjusted internally to a 0-based index (0 for January, 11 for December).
|
|
18
|
+
* - **`date`**: A number between 1 and 31 representing the day of the month.
|
|
19
|
+
* - **`hours`**: A number between 0 and 23 representing the hour of the day.
|
|
20
|
+
* - **`minutes`**: A number between 0 and 59 representing the minutes past the hour.
|
|
21
|
+
* - **`seconds`**: A number between 0 and 59 representing the seconds past the minute.
|
|
22
|
+
* - **`milliseconds`**: A number between 0 and 999 representing the milliseconds past the second.
|
|
15
23
|
*
|
|
16
24
|
* This function also allows you to access static methods from the `Chronos` class, as it copies all static methods from `Chronos` to the `chronos` function itself.
|
|
17
25
|
* Therefore, static methods can be called either through the `Chronos` class directly or through the `chronos` function.
|
|
@@ -26,8 +34,15 @@ import { Chronos } from '..';
|
|
|
26
34
|
* const sameInstanceClass = Chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
27
35
|
* ```
|
|
28
36
|
*
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
37
|
+
* @param valueOrYear The value in number, string, Date or Chronos format or the full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
|
38
|
+
* @param month The month as a number between 1 and 12 (January to December).
|
|
39
|
+
* @param date The date as a number between 1 and 31.
|
|
40
|
+
* @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
|
41
|
+
* @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
|
|
42
|
+
* @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
|
|
43
|
+
* @param ms A number from 0 to 999 that specifies the milliseconds.
|
|
44
|
+
*
|
|
45
|
+
* @returns new `Chronos` instance representing the provided date with all methods and properties.
|
|
31
46
|
*
|
|
32
47
|
* @static
|
|
33
48
|
* @remarks
|
|
@@ -39,9 +54,47 @@ import { Chronos } from '..';
|
|
|
39
54
|
* Chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
40
55
|
* ```
|
|
41
56
|
*/
|
|
42
|
-
const chronos = ((date) => {
|
|
43
|
-
|
|
57
|
+
const chronos = ((valueOrYear, month, date, hours, minutes, seconds, ms) => {
|
|
58
|
+
let newChronos;
|
|
59
|
+
if (typeof valueOrYear === 'number' && typeof month === 'number') {
|
|
60
|
+
newChronos = new Chronos(valueOrYear, month, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
newChronos = new Chronos(valueOrYear);
|
|
64
|
+
}
|
|
65
|
+
return newChronos;
|
|
44
66
|
});
|
|
67
|
+
/**
|
|
68
|
+
* @static
|
|
69
|
+
* @remarks
|
|
70
|
+
* Static methods from the `Chronos` class are copied over to the `chronos` function.
|
|
71
|
+
* Therefore, you can access static methods from `Chronos` both through the `Chronos` class and the `chronos` function.
|
|
72
|
+
*
|
|
73
|
+
* Example usage:
|
|
74
|
+
* ```ts
|
|
75
|
+
* chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
76
|
+
* // Or
|
|
77
|
+
* Chronos.parse("2023-12-31", "YYYY-MM-DD");
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* *No need to call `chronos` for accessing the static methods. Simply call them.*
|
|
81
|
+
*
|
|
82
|
+
* **Available Static Methods:**
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* today(options?: FormatOptions): string
|
|
86
|
+
* now(): number
|
|
87
|
+
* parse(dateStr: string, format: string): Chronos
|
|
88
|
+
* utc(dateLike: ChronosInput): Chronos
|
|
89
|
+
* min(...dates: (ChronosInput)[]): Chronos
|
|
90
|
+
* max(...dates: (ChronosInput)[]): Chronos
|
|
91
|
+
* isLeapYear(date: ChronosInput): boolean
|
|
92
|
+
* isValidDate(value: unknown): boolean
|
|
93
|
+
* isDateString(value: unknown): boolean
|
|
94
|
+
* isValidChronos(value: unknown): boolean
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
const typedChronos = chronos;
|
|
45
98
|
// ? Add static methods from Chronos class to the chronos function
|
|
46
99
|
Object.getOwnPropertyNames(Chronos).forEach((method) => {
|
|
47
100
|
// Exclude non-method properties like `length`, `name`, `prototype`
|
|
@@ -60,4 +113,4 @@ Object.getOwnPropertyNames(Chronos).forEach((method) => {
|
|
|
60
113
|
// };
|
|
61
114
|
// }
|
|
62
115
|
// });
|
|
63
|
-
export { chronos };
|
|
116
|
+
export { typedChronos as chronos };
|
package/dist/date/types.d.ts
CHANGED
|
@@ -78,12 +78,85 @@ export type ChronosMethods = {
|
|
|
78
78
|
[key in K]: (...args: any[]) => Chronos;
|
|
79
79
|
} ? K : never;
|
|
80
80
|
}[keyof typeof Chronos];
|
|
81
|
+
/** Accepted Input type for `Chronos` */
|
|
82
|
+
export type ChronosInput = number | string | Date | Chronos;
|
|
81
83
|
/** All the statics methods in `Chronos` class */
|
|
82
84
|
export interface ChronosStatics {
|
|
83
|
-
|
|
85
|
+
/**
|
|
86
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
87
|
+
*
|
|
88
|
+
* @description
|
|
89
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
90
|
+
*
|
|
91
|
+
* Accepts no arguments (defaults to now).
|
|
92
|
+
*
|
|
93
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
94
|
+
*/
|
|
95
|
+
(): Chronos;
|
|
96
|
+
/**
|
|
97
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
98
|
+
*
|
|
99
|
+
* @description
|
|
100
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
101
|
+
*
|
|
102
|
+
* @param value - A date value in `number`, it should be a timestamp (milliseconds since the Unix epoch).
|
|
103
|
+
*
|
|
104
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
105
|
+
*/
|
|
106
|
+
(value: number): Chronos;
|
|
107
|
+
/**
|
|
108
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
109
|
+
*
|
|
110
|
+
* @description
|
|
111
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
112
|
+
*
|
|
113
|
+
* @param value - A date value in `string`, it should be in a format that can be parsed by the `Date` constructor.
|
|
114
|
+
*
|
|
115
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
116
|
+
*/
|
|
117
|
+
(value: string): Chronos;
|
|
118
|
+
/**
|
|
119
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
120
|
+
*
|
|
121
|
+
* @description
|
|
122
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
123
|
+
*
|
|
124
|
+
* @param value - A date value as `Date` object, it will be used as is.
|
|
125
|
+
*
|
|
126
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
127
|
+
*/
|
|
128
|
+
(value: Date): Chronos;
|
|
129
|
+
/**
|
|
130
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
131
|
+
*
|
|
132
|
+
* @description
|
|
133
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
134
|
+
*
|
|
135
|
+
* @param value - A date value as `Chronos` object.
|
|
136
|
+
*
|
|
137
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
138
|
+
*/
|
|
139
|
+
(value: Chronos): Chronos;
|
|
140
|
+
/**
|
|
141
|
+
* * Converts a date into a `Chronos` object and access to all `Chronos` methods and properties.
|
|
142
|
+
*
|
|
143
|
+
* @description
|
|
144
|
+
* This function serves as a wrapper around the `Chronos` class constructor and allows you to create a new `Chronos` instance from various types of date representations.
|
|
145
|
+
*
|
|
146
|
+
* @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
|
147
|
+
* @param month The month as a number between 1 and 12 (January to December).
|
|
148
|
+
* @param date The date as a number between 1 and 31.
|
|
149
|
+
* @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
|
150
|
+
* @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
|
|
151
|
+
* @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
|
|
152
|
+
* @param ms A number from 0 to 999 that specifies the milliseconds.
|
|
153
|
+
*
|
|
154
|
+
* @returns Instance of `Chronos` with all methods and properties.
|
|
155
|
+
*/
|
|
156
|
+
(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Chronos;
|
|
84
157
|
/**
|
|
85
158
|
* * Returns the current date and time in a specified format in local time.
|
|
86
|
-
* * Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
159
|
+
* * Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
87
160
|
* @param options - Configure format string and whether to format using utc offset.
|
|
88
161
|
* @returns Formatted date string in desired format.
|
|
89
162
|
*/
|
|
@@ -112,27 +185,27 @@ export interface ChronosStatics {
|
|
|
112
185
|
* // returns Chronos instance with the parsed date 2023-12-31T15:30:45
|
|
113
186
|
* ```
|
|
114
187
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @returns
|
|
118
|
-
* @throws
|
|
188
|
+
* @param dateStr - The date string to be parsed
|
|
189
|
+
* @param format - The format of the date string. Tokens like `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss` are used to specify the structure.
|
|
190
|
+
* @returns A new `Chronos` instance representing the parsed date.
|
|
191
|
+
* @throws `Error` If the date string does not match the format.
|
|
119
192
|
*/
|
|
120
193
|
parse(dateStr: string, format: string): Chronos;
|
|
121
194
|
/**
|
|
122
195
|
* * Creates UTC Chronos
|
|
123
196
|
* @param dateLike Date input to create utc time.
|
|
124
197
|
*/
|
|
125
|
-
utc(dateLike:
|
|
198
|
+
utc(dateLike: ChronosInput): Chronos;
|
|
126
199
|
/**
|
|
127
200
|
* * Returns earliest Chronos
|
|
128
201
|
* @param dates Date inputs.
|
|
129
202
|
*/
|
|
130
|
-
min(...dates:
|
|
203
|
+
min(...dates: ChronosInput[]): Chronos;
|
|
131
204
|
/**
|
|
132
205
|
* * Returns latest Chronos
|
|
133
206
|
* @param dates Date inputs.
|
|
134
207
|
*/
|
|
135
|
-
max(...dates:
|
|
208
|
+
max(...dates: ChronosInput[]): Chronos;
|
|
136
209
|
/**
|
|
137
210
|
* * Checks if the year in the date string or year (from 0 - 9999) is a leap year.
|
|
138
211
|
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
@@ -148,7 +221,7 @@ export interface ChronosStatics {
|
|
|
148
221
|
* @param date - A `number` (year or Unix timestamp), `string`, `Date`, or `Chronos` instance representing a date.
|
|
149
222
|
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
150
223
|
*/
|
|
151
|
-
isLeapYear(date:
|
|
224
|
+
isLeapYear(date: ChronosInput): boolean;
|
|
152
225
|
/**
|
|
153
226
|
* * Checks if the given value is a valid `Date` object.
|
|
154
227
|
* - A value is considered valid if it is an instance of the built-in `Date` class.
|
|
@@ -156,7 +229,7 @@ export interface ChronosStatics {
|
|
|
156
229
|
* @param value - The value to test.
|
|
157
230
|
* @returns `true` if the value is a valid Date object, otherwise `false`.
|
|
158
231
|
*/
|
|
159
|
-
isValidDate(value: unknown): value is
|
|
232
|
+
isValidDate(value: unknown): value is Date;
|
|
160
233
|
/**
|
|
161
234
|
* * Checks if the given value is a valid date string.
|
|
162
235
|
* - A value is considered a valid date string if it is a string and can be parsed by `Date.parse()`.
|
|
@@ -180,7 +253,7 @@ export type UTCMinute = '00' | '15' | '30' | '45';
|
|
|
180
253
|
export type UTCOffSet = `UTC${PositiveUTCHour | NegativeUTCHour}:${UTCMinute}`;
|
|
181
254
|
/** * Format options */
|
|
182
255
|
export interface FormatOptions {
|
|
183
|
-
/** - The desired format (Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55
|
|
256
|
+
/** - The desired format (Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55). */
|
|
184
257
|
format?: string;
|
|
185
258
|
/** - Whether to use UTC time. Defaults to `false`. */
|
|
186
259
|
useUTC?: boolean;
|
package/dist/date/types.d.ts.map
CHANGED
|
@@ -1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ACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAET,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,MAAM,eAAe,GAAG,eAAe,IAAI,SAAS,EAAE,CAAC;AAE/E,uBAAuB;AACvB,MAAM,WAAW,aAAa;IAC7B,0GAA0G;IAC1G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
package/dist/date/utils.js
CHANGED
|
@@ -39,7 +39,7 @@ export function getCurrentDateTime() {
|
|
|
39
39
|
// * - If a Chronos object is provided, it will be converted to a Date object.
|
|
40
40
|
// * @returns A new Chronos object representing the provided date.
|
|
41
41
|
// */
|
|
42
|
-
// export function chronos(date?:
|
|
42
|
+
// export function chronos(date?: ChronosInput) {
|
|
43
43
|
// return new Chronos(date);
|
|
44
44
|
// }
|
|
45
45
|
/**
|
package/package.json
CHANGED