nhb-toolbox 3.7.5 → 3.7.9
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/date/Chronos.d.ts +150 -138
- package/dist/date/Chronos.d.ts.map +1 -1
- package/dist/date/Chronos.js +352 -300
- package/dist/date/constants.d.ts +1 -0
- package/dist/date/constants.d.ts.map +1 -1
- package/dist/date/constants.js +1 -0
- package/dist/date/types.d.ts +24 -1
- package/dist/date/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/date/Chronos.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { LocaleCode } from '../number/types';
|
|
2
|
-
import
|
|
2
|
+
import { ORIGIN } from './constants';
|
|
3
|
+
import type { ChronosMethods, ChronosObject, FormatOptions, TimeUnit, TimeZone, UTCOffSet } from './types';
|
|
3
4
|
export declare class Chronos {
|
|
4
5
|
#private;
|
|
6
|
+
[ORIGIN]?: ChronosMethods | 'root';
|
|
5
7
|
/**
|
|
6
8
|
* * Creates a new immutable `Chronos` instance.
|
|
7
9
|
*
|
|
@@ -12,71 +14,72 @@ export declare class Chronos {
|
|
|
12
14
|
* - If a Chronos object is provided, it will be converted to a Date object.
|
|
13
15
|
*/
|
|
14
16
|
constructor(value?: number | string | Date | Chronos);
|
|
15
|
-
|
|
17
|
+
[Symbol.iterator](): IterableIterator<[string, number]>;
|
|
16
18
|
/**
|
|
17
19
|
* * Enables primitive coercion like `console.log`, `${chronos}`, etc.
|
|
18
20
|
* @param hint - The type hint provided by the JS engine.
|
|
19
21
|
* @returns The primitive value based on the hint.
|
|
20
22
|
*/
|
|
21
23
|
[Symbol.toPrimitive](hint: string): string | number;
|
|
22
|
-
|
|
24
|
+
get [Symbol.toStringTag](): string;
|
|
25
|
+
/** Gets the full year of the date. */
|
|
26
|
+
get year(): number;
|
|
27
|
+
/** Gets the month (0-11) of the date. */
|
|
28
|
+
get month(): number;
|
|
29
|
+
/** Gets the day of the month (1-31). */
|
|
30
|
+
get date(): number;
|
|
31
|
+
/** Gets the day of the week (0-6, where 0 is Sunday). */
|
|
32
|
+
get weekDay(): number;
|
|
33
|
+
/** Gets the hour (0-23) of the date. */
|
|
34
|
+
get hour(): number;
|
|
35
|
+
/** Gets the minute (0-59) of the date. */
|
|
36
|
+
get minute(): number;
|
|
37
|
+
/** Gets the second (0-59) of the date. */
|
|
38
|
+
get second(): number;
|
|
39
|
+
/** Gets the millisecond (0-999) of the date. */
|
|
40
|
+
get millisecond(): number;
|
|
41
|
+
/** Gets ISO weekday: 1 = Monday, 7 = Sunday */
|
|
42
|
+
get isoWeekday(): number;
|
|
43
|
+
/** Gets ISO month (1–12 instead of 0–11) */
|
|
44
|
+
get isoMonth(): number;
|
|
45
|
+
/** Gets the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
46
|
+
get unix(): number;
|
|
47
|
+
/** @public @instance Returns a debug-friendly string for console.log or util.inspect */
|
|
48
|
+
inspect(): string;
|
|
49
|
+
/** @public @instance Clones and returns a new Chronos instance with the same date. */
|
|
23
50
|
clone(): Chronos;
|
|
24
|
-
/**
|
|
51
|
+
/** @public @instance Enables JSON.stringify and console logging to show readable output. */
|
|
25
52
|
toJSON(): string;
|
|
26
|
-
/**
|
|
53
|
+
/** @public @instance Enables arithmetic and comparison operations (e.g., +new Chronos()). */
|
|
27
54
|
valueOf(): number;
|
|
28
|
-
/**
|
|
55
|
+
/** @public @instance Gets the native `Date` instance (read-only). */
|
|
29
56
|
toDate(): Date;
|
|
30
|
-
/**
|
|
57
|
+
/** @public @instance Returns a string representation of a date. The format of the string depends on the locale. */
|
|
31
58
|
toString(): string;
|
|
32
|
-
/**
|
|
59
|
+
/** @public @instance Returns ISO string with local time zone offset */
|
|
33
60
|
toLocalISOString(): string;
|
|
61
|
+
/** @public @instance Returns a date as a string value in ISO format. */
|
|
62
|
+
toISOString(): string;
|
|
34
63
|
/**
|
|
35
|
-
*
|
|
64
|
+
* @public @instance Wrapper over native `toLocaleString`
|
|
36
65
|
* @description Converts a date and time to a string by using the current or specified locale.
|
|
37
66
|
*
|
|
38
67
|
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
|
39
68
|
* @param options An object that contains one or more properties that specify comparison options.
|
|
40
69
|
*/
|
|
41
70
|
toLocaleString(locale?: LocaleCode | Intl.Locale | (LocaleCode | Intl.Locale)[], options?: Intl.DateTimeFormatOptions): string;
|
|
42
|
-
/**
|
|
43
|
-
toISOString(): string;
|
|
44
|
-
/** * Returns the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
71
|
+
/** @public @instance Returns the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
45
72
|
getTimeStamp(): number;
|
|
46
|
-
/** * Returns the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
47
|
-
get unix(): number;
|
|
48
|
-
get year(): number;
|
|
49
|
-
get month(): number;
|
|
50
|
-
get date(): number;
|
|
51
|
-
get day(): number;
|
|
52
|
-
get hour(): number;
|
|
53
|
-
get minute(): number;
|
|
54
|
-
get second(): number;
|
|
55
|
-
get millisecond(): number;
|
|
56
|
-
/** * ISO weekday: 1 = Monday, 7 = Sunday */
|
|
57
|
-
get isoWeekday(): number;
|
|
58
73
|
/**
|
|
59
|
-
* @instance Returns the current date and time in a specified format in local time.
|
|
60
|
-
*
|
|
74
|
+
* @public @instance Returns the current date and time in a specified format in local time.
|
|
75
|
+
* @description Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55:379`
|
|
76
|
+
*
|
|
61
77
|
* @param options - Configure format string and whether to format using utc offset.
|
|
62
78
|
* @returns Formatted date string in desired format.
|
|
63
79
|
*/
|
|
64
80
|
today(options?: FormatOptions): string;
|
|
65
81
|
/**
|
|
66
|
-
* @
|
|
67
|
-
* * Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55:379`
|
|
68
|
-
* @param options - Configure format string and whether to format using utc offset.
|
|
69
|
-
* @returns Formatted date string in desired format.
|
|
70
|
-
*/
|
|
71
|
-
static today(options?: FormatOptions): string;
|
|
72
|
-
/**
|
|
73
|
-
* * Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
74
|
-
* * It basically calls `Date.now()`.
|
|
75
|
-
* @returns The number of milliseconds elapsed since the Unix epoch.
|
|
76
|
-
*/
|
|
77
|
-
static now(): number;
|
|
78
|
-
/**
|
|
79
|
-
* * Formats the date into a custom string format (local time).
|
|
82
|
+
* @public @instance Formats the date into a custom string format (local time).
|
|
80
83
|
*
|
|
81
84
|
* @param format - The desired format (Default format is `dd, MMM DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
82
85
|
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`. Equivalent to `formatUTC()` method if set to `true`.
|
|
@@ -84,76 +87,104 @@ export declare class Chronos {
|
|
|
84
87
|
*/
|
|
85
88
|
format(format?: string, useUTC?: boolean): string;
|
|
86
89
|
/**
|
|
87
|
-
*
|
|
90
|
+
* @public @instance Formats the date into a custom string format (UTC time).
|
|
88
91
|
*
|
|
89
92
|
* @param format - The desired format (Default format is `dd, MMM DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
90
93
|
* @returns Formatted date string in desired format (UTC time).
|
|
91
94
|
*/
|
|
92
95
|
formatUTC(format?: string): string;
|
|
93
96
|
/**
|
|
94
|
-
*
|
|
97
|
+
* @public @instance Adds seconds and returns a new immutable instance.
|
|
95
98
|
* @param seconds - Number of seconds to add.
|
|
96
99
|
* @returns A new `Chronos` instance with the updated date.
|
|
97
100
|
*/
|
|
98
101
|
addSeconds(seconds: number): Chronos;
|
|
99
102
|
/**
|
|
100
|
-
*
|
|
103
|
+
* @public @instance Adds minutes and returns a new immutable instance.
|
|
101
104
|
* @param minutes - Number of minutes to add.
|
|
102
105
|
* @returns A new `Chronos` instance with the updated date.
|
|
103
106
|
*/
|
|
104
107
|
addMinutes(minutes: number): Chronos;
|
|
105
108
|
/**
|
|
106
|
-
*
|
|
109
|
+
* @public @instance Adds hours and returns a new immutable instance.
|
|
107
110
|
* @param hours - Number of hours to add.
|
|
108
111
|
* @returns A new `Chronos` instance with the updated date.
|
|
109
112
|
*/
|
|
110
113
|
addHours(hours: number): Chronos;
|
|
111
114
|
/**
|
|
112
|
-
*
|
|
115
|
+
* @public @instance Adds days and returns a new immutable instance.
|
|
113
116
|
* @param days - Number of days to add.
|
|
114
117
|
* @returns A new `Chronos` instance with the updated date.
|
|
115
118
|
*/
|
|
116
119
|
addDays(days: number): Chronos;
|
|
117
120
|
/**
|
|
118
|
-
*
|
|
121
|
+
* @public @instance Adds months and returns a new immutable instance.
|
|
119
122
|
* @param months - Number of months to add.
|
|
120
123
|
* @returns A new `Chronos` instance with the updated date.
|
|
121
124
|
*/
|
|
122
125
|
addMonths(months: number): Chronos;
|
|
123
126
|
/**
|
|
124
|
-
*
|
|
127
|
+
* @public @instance Adds years and returns a new immutable instance.
|
|
125
128
|
* @param years - Number of years to add.
|
|
126
129
|
* @returns A new `Chronos` instance with the updated date.
|
|
127
130
|
*/
|
|
128
131
|
addYears(years: number): Chronos;
|
|
129
132
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @
|
|
133
|
+
* @public @instance Create a new instance of `Chronos` in the specified timezone.
|
|
134
|
+
*
|
|
135
|
+
* @param zone - Standard timezone abbreviation (e.g., 'IST', 'UTC', 'EST') or UTC Offset in `UTC-01:30` format.
|
|
136
|
+
* @returns A new instance of `Chronos` with time in the given timezone. Invalid input sets time-zone to `UTC`.
|
|
133
137
|
*/
|
|
134
|
-
|
|
138
|
+
timeZone(zone: TimeZone | UTCOffSet): Chronos;
|
|
135
139
|
/**
|
|
136
|
-
*
|
|
140
|
+
* @public @instance Checks if the year is a leap year.
|
|
137
141
|
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
138
142
|
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
139
143
|
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
140
144
|
*/
|
|
141
145
|
isLeapYear(): boolean;
|
|
142
|
-
/**
|
|
143
|
-
* * Create a new instance of `Chronos` in the specified timezone.
|
|
144
|
-
*
|
|
145
|
-
* @param zone - Standard timezone abbreviation (e.g., 'IST', 'UTC', 'EST') or UTC Offset in `UTC-01:30` format.
|
|
146
|
-
* @returns A new instance of `Chronos` with time in the given timezone. Invalid input sets time-zone to `UTC`.
|
|
147
|
-
*/
|
|
148
|
-
timeZone(zone: TimeZone | UTCOffSet): Chronos;
|
|
149
|
-
/** - Checks if the current date is today. */
|
|
146
|
+
/** @public @instance Checks if the current date is today. */
|
|
150
147
|
isToday(): boolean;
|
|
151
|
-
/**
|
|
148
|
+
/** @public @instance Checks if the current date is tomorrow. */
|
|
152
149
|
isTomorrow(): boolean;
|
|
153
|
-
/**
|
|
150
|
+
/** @public @instance Checks if the current date is yesterday. */
|
|
154
151
|
isYesterday(): boolean;
|
|
155
152
|
/**
|
|
156
|
-
*
|
|
153
|
+
* @public @instance Checks if another date is the same as this one in a specific unit.
|
|
154
|
+
* @param other The other date to compare.
|
|
155
|
+
* @param unit The unit to compare.
|
|
156
|
+
*/
|
|
157
|
+
isSame(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* @public @instance Checks if this date is before another date in a specific unit.
|
|
160
|
+
* @param other The other date to compare.
|
|
161
|
+
* @param unit The unit to compare.
|
|
162
|
+
*/
|
|
163
|
+
isBefore(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* @public @instance Checks if this date is after another date in a specific unit.
|
|
166
|
+
* @param other The other date to compare.
|
|
167
|
+
* @param unit The unit to compare.
|
|
168
|
+
*/
|
|
169
|
+
isAfter(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* @public @instance Checks if the current date is between the given start and end dates.
|
|
172
|
+
*
|
|
173
|
+
* @param start - The start of the range.
|
|
174
|
+
* @param end - The end of the range.
|
|
175
|
+
* @param inclusive - Specifies whether the comparison is inclusive or exclusive:
|
|
176
|
+
* - `'[]'`: inclusive of both start and end (≥ start and ≤ end)
|
|
177
|
+
* - `'[)'`: inclusive of start, exclusive of end (≥ start and < end)
|
|
178
|
+
* - `'(]'`: exclusive of start, inclusive of end (> start and ≤ end)
|
|
179
|
+
* - `'()'`: exclusive of both start and end (> start and < end)
|
|
180
|
+
*
|
|
181
|
+
* @returns `true` if the current date is within the specified range based on the `inclusive` mode.
|
|
182
|
+
*/
|
|
183
|
+
isBetween(start: number | string | Date | Chronos, end: number | string | Date | Chronos, inclusive?: '[]' | '[)' | '(]' | '()'): boolean;
|
|
184
|
+
/** @public @instance Checks if currently in DST */
|
|
185
|
+
isDST(): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* @public @instance Returns full time difference from now (or a specified time) down to a given level.
|
|
157
188
|
*
|
|
158
189
|
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `minute`.
|
|
159
190
|
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
@@ -162,19 +193,19 @@ export declare class Chronos {
|
|
|
162
193
|
*/
|
|
163
194
|
fromNow(level?: Exclude<TimeUnit, 'millisecond'>, withSuffixPrefix?: boolean, time?: number | string | Date | Chronos): string;
|
|
164
195
|
/**
|
|
165
|
-
*
|
|
196
|
+
* @public @instance Returns the number of full years between the input date and now.
|
|
166
197
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
167
198
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
168
199
|
*/
|
|
169
200
|
getRelativeYear(time?: number | string | Date | Chronos): number;
|
|
170
201
|
/**
|
|
171
|
-
*
|
|
202
|
+
* @public @instance Returns the number of full months between the input date and now.
|
|
172
203
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
173
204
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
174
205
|
*/
|
|
175
206
|
getRelativeMonth(time?: number | string | Date | Chronos): number;
|
|
176
207
|
/**
|
|
177
|
-
*
|
|
208
|
+
* @public @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
178
209
|
* @param date - The date to compare (Date object).
|
|
179
210
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
180
211
|
* @returns
|
|
@@ -185,31 +216,31 @@ export declare class Chronos {
|
|
|
185
216
|
*/
|
|
186
217
|
getRelativeDay(time?: number | string | Date | Chronos): number;
|
|
187
218
|
/**
|
|
188
|
-
*
|
|
219
|
+
* @public @instance Returns the number of full hours between the input date and now.
|
|
189
220
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
190
221
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
191
222
|
*/
|
|
192
223
|
getRelativeHour(time?: number | string | Date | Chronos): number;
|
|
193
224
|
/**
|
|
194
|
-
*
|
|
225
|
+
* @public @instance Returns the number of full minutes between the input date and now.
|
|
195
226
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
196
227
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
197
228
|
*/
|
|
198
229
|
getRelativeMinute(time?: number | string | Date | Chronos): number;
|
|
199
230
|
/**
|
|
200
|
-
*
|
|
231
|
+
* @public @instance Returns the number of full seconds between the input date and now.
|
|
201
232
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
202
233
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
203
234
|
*/
|
|
204
235
|
getRelativeSecond(time?: number | string | Date | Chronos): number;
|
|
205
236
|
/**
|
|
206
|
-
*
|
|
237
|
+
* @public @instance Returns the number of milliseconds between the input date and now.
|
|
207
238
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
208
239
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
209
240
|
*/
|
|
210
241
|
getRelativeMilliSecond(time?: number | string | Date | Chronos): number;
|
|
211
242
|
/**
|
|
212
|
-
*
|
|
243
|
+
* @public @instance Compares the stored date with now, returning the difference in the specified unit.
|
|
213
244
|
*
|
|
214
245
|
* @param unit The time unit to compare by. Defaults to 'minute'.
|
|
215
246
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
@@ -217,115 +248,96 @@ export declare class Chronos {
|
|
|
217
248
|
*/
|
|
218
249
|
compare(unit?: TimeUnit, time?: number | string | Date | Chronos): number;
|
|
219
250
|
/**
|
|
220
|
-
*
|
|
251
|
+
* @public @instance Returns a new Chronos instance at the start of a given unit.
|
|
221
252
|
* @param unit The unit to reset (e.g., year, month, day).
|
|
222
253
|
*/
|
|
223
254
|
startOf(unit: TimeUnit | 'week'): Chronos;
|
|
224
255
|
/**
|
|
225
|
-
*
|
|
256
|
+
* @public @instance Returns a new Chronos instance at the end of a given unit.
|
|
226
257
|
* @param unit The unit to adjust (e.g., year, month, day).
|
|
227
258
|
*/
|
|
228
259
|
endOf(unit: TimeUnit): Chronos;
|
|
229
260
|
/**
|
|
230
|
-
*
|
|
261
|
+
* @public @instance Returns a new Chronos instance with the specified unit added.
|
|
231
262
|
* @param amount The amount to add (can be negative).
|
|
232
263
|
* @param unit The time unit to add.
|
|
233
264
|
*/
|
|
234
265
|
add(amount: number, unit: TimeUnit): Chronos;
|
|
235
266
|
/**
|
|
236
|
-
*
|
|
267
|
+
* @public @instance Returns a new Chronos instance with the specified unit subtracted.
|
|
268
|
+
* @param amount The amount to subtract (can be negative).
|
|
269
|
+
* @param unit The time unit to add.
|
|
270
|
+
*/
|
|
271
|
+
subtract(amount: number, unit: TimeUnit): Chronos;
|
|
272
|
+
/**
|
|
273
|
+
* @public @instance Gets the value of a specific time unit from the date.
|
|
237
274
|
* @param unit The unit to retrieve.
|
|
238
275
|
*/
|
|
239
276
|
get(unit: TimeUnit): number;
|
|
240
277
|
/**
|
|
241
|
-
* Returns a new Chronos instance with the specified unit set to the given value.
|
|
278
|
+
* @public @instance Returns a new Chronos instance with the specified unit set to the given value.
|
|
242
279
|
* @param unit The unit to modify.
|
|
243
280
|
* @param value The value to set for the unit.
|
|
244
281
|
*/
|
|
245
282
|
set(unit: TimeUnit, value: number): Chronos;
|
|
246
283
|
/**
|
|
247
|
-
*
|
|
284
|
+
* @public @instance Returns the difference between this and another date in the given unit.
|
|
248
285
|
* @param other The other date to compare.
|
|
249
286
|
* @param unit The unit in which to return the difference.
|
|
250
287
|
*/
|
|
251
288
|
diff(other: number | string | Date | Chronos, unit: TimeUnit): number;
|
|
252
289
|
/**
|
|
253
|
-
*
|
|
254
|
-
* @param other The other date to compare.
|
|
255
|
-
* @param unit The unit to compare.
|
|
256
|
-
*/
|
|
257
|
-
isSame(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
258
|
-
/**
|
|
259
|
-
* * Checks if this date is before another date in a specific unit.
|
|
260
|
-
* @param other The other date to compare.
|
|
261
|
-
* @param unit The unit to compare.
|
|
262
|
-
*/
|
|
263
|
-
isBefore(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
264
|
-
/**
|
|
265
|
-
* * Checks if this date is after another date in a specific unit.
|
|
266
|
-
* @param other The other date to compare.
|
|
267
|
-
* @param unit The unit to compare.
|
|
268
|
-
*/
|
|
269
|
-
isAfter(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
270
|
-
/**
|
|
271
|
-
* * Returns a human-readable relative calendar time like "Today at 3:00 PM"
|
|
290
|
+
* @public @instance Returns a human-readable relative calendar time like "Today at 3:00 PM"
|
|
272
291
|
* @param baseDate Optional base date to compare with.
|
|
273
292
|
*/
|
|
274
293
|
calendar(baseDate?: number | string | Date | Chronos): string;
|
|
275
|
-
/**
|
|
294
|
+
/** @public @instance Returns a short human-readable string like "2h ago", "in 5m" */
|
|
276
295
|
fromNowShort(): string;
|
|
277
|
-
/**
|
|
296
|
+
/** @public @instance Returns ISO week number */
|
|
278
297
|
getWeek(): number;
|
|
279
|
-
/**
|
|
298
|
+
/** @public @instance Returns ISO week year */
|
|
280
299
|
getWeekYear(): number;
|
|
281
|
-
/**
|
|
300
|
+
/** @public @instance Returns day of year (1 - 366) */
|
|
282
301
|
getDayOfYear(): number;
|
|
283
|
-
/**
|
|
284
|
-
* * Checks if the current date is between the given start and end dates.
|
|
285
|
-
*
|
|
286
|
-
* @param start - The start of the range.
|
|
287
|
-
* @param end - The end of the range.
|
|
288
|
-
* @param inclusive - Specifies whether the comparison is inclusive or exclusive:
|
|
289
|
-
* - `'[]'`: inclusive of both start and end (≥ start and ≤ end)
|
|
290
|
-
* - `'[)'`: inclusive of start, exclusive of end (≥ start and < end)
|
|
291
|
-
* - `'(]'`: exclusive of start, inclusive of end (> start and ≤ end)
|
|
292
|
-
* - `'()'`: exclusive of both start and end (> start and < end)
|
|
293
|
-
*
|
|
294
|
-
* @returns `true` if the current date is within the specified range based on the `inclusive` mode.
|
|
295
|
-
*/
|
|
296
|
-
isBetween(start: number | string | Date | Chronos, end: number | string | Date | Chronos, inclusive?: '[]' | '[)' | '(]' | '()'): boolean;
|
|
297
|
-
/** * Returns number of days in current month */
|
|
302
|
+
/** @public @instance Returns number of days in current month */
|
|
298
303
|
daysInMonth(): number;
|
|
299
|
-
/**
|
|
300
|
-
toObject():
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
date: number;
|
|
305
|
-
day: number;
|
|
306
|
-
isoDay: number;
|
|
307
|
-
hour: number;
|
|
308
|
-
minute: number;
|
|
309
|
-
second: number;
|
|
310
|
-
millisecond: number;
|
|
311
|
-
};
|
|
312
|
-
/** * Converts to array with all date unit parts */
|
|
313
|
-
toArray(): [number, number, number, number, number, number, number];
|
|
314
|
-
/** * Returns offset like +06:00 */
|
|
304
|
+
/** @public @instance Converts to object with all date unit parts */
|
|
305
|
+
toObject(): ChronosObject;
|
|
306
|
+
/** @public @instance Converts to array with all date unit parts */
|
|
307
|
+
toArray(): any[];
|
|
308
|
+
/** @public @instance Returns offset like +06:00 */
|
|
315
309
|
getUTCOffset(): string;
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
/**
|
|
310
|
+
/** @public @instance Returns new Chronos instance in UTC */
|
|
311
|
+
toUTC(): Chronos;
|
|
312
|
+
/** @public @instance Returns new Chronos instance in local time */
|
|
313
|
+
toLocal(): Chronos;
|
|
314
|
+
/**
|
|
315
|
+
* @public @static Returns the current date and time in a specified format in local time.
|
|
316
|
+
* * Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55:379`
|
|
317
|
+
* @param options - Configure format string and whether to format using utc offset.
|
|
318
|
+
* @returns Formatted date string in desired format.
|
|
319
|
+
*/
|
|
320
|
+
static today(options?: FormatOptions): string;
|
|
321
|
+
/**
|
|
322
|
+
* @public @static Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
323
|
+
* * It basically calls `Date.now()`.
|
|
324
|
+
* @returns The number of milliseconds elapsed since the Unix epoch.
|
|
325
|
+
*/
|
|
326
|
+
static now(): number;
|
|
327
|
+
/** @public @static Parses a date string with a given format (partial support) */
|
|
321
328
|
static parse(dateStr: string, format: string): Chronos;
|
|
322
329
|
/**
|
|
323
|
-
* @static
|
|
330
|
+
* @public @static Creates UTC Chronos
|
|
331
|
+
* @param dateLike Date input to create utc time.
|
|
332
|
+
*/
|
|
333
|
+
static utc(dateLike: number | string | Date | Chronos): Chronos;
|
|
334
|
+
/**
|
|
335
|
+
* @public @static Returns earliest Chronos
|
|
324
336
|
* @param dates Date inputs.
|
|
325
337
|
*/
|
|
326
338
|
static min(...dates: (number | string | Date | Chronos)[]): Chronos;
|
|
327
339
|
/**
|
|
328
|
-
* @static Returns latest Chronos
|
|
340
|
+
* @public @static Returns latest Chronos
|
|
329
341
|
* @param dates Date inputs.
|
|
330
342
|
*/
|
|
331
343
|
static max(...dates: (number | string | Date | Chronos)[]): Chronos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAgB,MAAM,EAA6B,MAAM,aAAa,CAAC;AAE9E,OAAO,KAAK,EAEX,cAAc,EACd,aAAa,EACb,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB,qBAAa,OAAO;;IAEnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC;;;;;;;;OAQG;gBACS,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO;IAOnD,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAaxD;;;;OAIG;IACH,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAKnD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAWjC;IA0HD,sCAAsC;IACtC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,yCAAyC;IACzC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,wCAAwC;IACxC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAA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