@naturalcycles/js-lib 14.186.0 → 14.187.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/dist/datetime/localDate.d.ts +14 -0
- package/dist/datetime/localDate.js +18 -0
- package/dist/datetime/localTime.d.ts +14 -0
- package/dist/datetime/localTime.js +18 -0
- package/dist-esm/datetime/localDate.js +18 -0
- package/dist-esm/datetime/localTime.js +18 -0
- package/package.json +1 -1
- package/src/datetime/localDate.ts +20 -0
- package/src/datetime/localTime.ts +20 -0
|
@@ -59,6 +59,16 @@ export declare class LocalDate {
|
|
|
59
59
|
* Third argument allows to override "today".
|
|
60
60
|
*/
|
|
61
61
|
isOlderThan(n: number, unit: LocalDateUnitStrict, today?: LocalDateInput): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if this localDate is younger than "today" by X units.
|
|
64
|
+
*
|
|
65
|
+
* Example:
|
|
66
|
+
*
|
|
67
|
+
* localDate(expirationDate).isYoungerThan(5, 'day')
|
|
68
|
+
*
|
|
69
|
+
* Third argument allows to override "today".
|
|
70
|
+
*/
|
|
71
|
+
isYoungerThan(n: number, unit: LocalDateUnitStrict, today?: LocalDateInput): boolean;
|
|
62
72
|
/**
|
|
63
73
|
* Returns 1 if this > d
|
|
64
74
|
* returns 0 if they are equal
|
|
@@ -77,6 +87,10 @@ export declare class LocalDate {
|
|
|
77
87
|
diff(d: LocalDateInput, unit: LocalDateUnit): number;
|
|
78
88
|
add(num: number, unit: LocalDateUnit, mutate?: boolean): LocalDate;
|
|
79
89
|
subtract(num: number, unit: LocalDateUnit, mutate?: boolean): LocalDate;
|
|
90
|
+
/**
|
|
91
|
+
* Alias to subtract
|
|
92
|
+
*/
|
|
93
|
+
minus(num: number, unit: LocalDateUnit, mutate?: boolean): LocalDate;
|
|
80
94
|
startOf(unit: LocalDateUnitStrict): LocalDate;
|
|
81
95
|
endOf(unit: LocalDateUnitStrict): LocalDate;
|
|
82
96
|
static getYearLength(year: number): number;
|
|
@@ -191,6 +191,18 @@ class LocalDate {
|
|
|
191
191
|
isOlderThan(n, unit, today) {
|
|
192
192
|
return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit));
|
|
193
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Checks if this localDate is younger than "today" by X units.
|
|
196
|
+
*
|
|
197
|
+
* Example:
|
|
198
|
+
*
|
|
199
|
+
* localDate(expirationDate).isYoungerThan(5, 'day')
|
|
200
|
+
*
|
|
201
|
+
* Third argument allows to override "today".
|
|
202
|
+
*/
|
|
203
|
+
isYoungerThan(n, unit, today) {
|
|
204
|
+
return !this.isOlderThan(n, unit, today);
|
|
205
|
+
}
|
|
194
206
|
/**
|
|
195
207
|
* Returns 1 if this > d
|
|
196
208
|
* returns 0 if they are equal
|
|
@@ -340,6 +352,12 @@ class LocalDate {
|
|
|
340
352
|
subtract(num, unit, mutate = false) {
|
|
341
353
|
return this.add(-num, unit, mutate);
|
|
342
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Alias to subtract
|
|
357
|
+
*/
|
|
358
|
+
minus(num, unit, mutate = false) {
|
|
359
|
+
return this.add(-num, unit, mutate);
|
|
360
|
+
}
|
|
343
361
|
startOf(unit) {
|
|
344
362
|
if (unit === 'day')
|
|
345
363
|
return this;
|
|
@@ -72,6 +72,10 @@ export declare class LocalTime {
|
|
|
72
72
|
setComponents(c: Partial<LocalTimeComponents>, mutate?: boolean): LocalTime;
|
|
73
73
|
add(num: number, unit: LocalTimeUnit, mutate?: boolean): LocalTime;
|
|
74
74
|
subtract(num: number, unit: LocalTimeUnit, mutate?: boolean): LocalTime;
|
|
75
|
+
/**
|
|
76
|
+
* Alias to subtract.
|
|
77
|
+
*/
|
|
78
|
+
minus(num: number, unit: LocalTimeUnit, mutate?: boolean): LocalTime;
|
|
75
79
|
absDiff(other: LocalTimeInput, unit: LocalTimeUnit): number;
|
|
76
80
|
diff(other: LocalTimeInput, unit: LocalTimeUnit): number;
|
|
77
81
|
startOf(unit: LocalTimeUnit, mutate?: boolean): LocalTime;
|
|
@@ -97,6 +101,16 @@ export declare class LocalTime {
|
|
|
97
101
|
* Third argument allows to override "now".
|
|
98
102
|
*/
|
|
99
103
|
isOlderThan(n: number, unit: LocalTimeUnit, now?: LocalTimeInput): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Checks if this localTime is younger than "now" by X units.
|
|
106
|
+
*
|
|
107
|
+
* Example:
|
|
108
|
+
*
|
|
109
|
+
* localTime(expirationDate).isYoungerThan(5, 'day')
|
|
110
|
+
*
|
|
111
|
+
* Third argument allows to override "now".
|
|
112
|
+
*/
|
|
113
|
+
isYoungerThan(n: number, unit: LocalTimeUnit, now?: LocalTimeInput): boolean;
|
|
100
114
|
/**
|
|
101
115
|
* Returns 1 if this > d
|
|
102
116
|
* returns 0 if they are equal
|
|
@@ -214,6 +214,12 @@ class LocalTime {
|
|
|
214
214
|
subtract(num, unit, mutate = false) {
|
|
215
215
|
return this.add(num * -1, unit, mutate);
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Alias to subtract.
|
|
219
|
+
*/
|
|
220
|
+
minus(num, unit, mutate = false) {
|
|
221
|
+
return this.add(num * -1, unit, mutate);
|
|
222
|
+
}
|
|
217
223
|
absDiff(other, unit) {
|
|
218
224
|
return Math.abs(this.diff(other, unit));
|
|
219
225
|
}
|
|
@@ -369,6 +375,18 @@ class LocalTime {
|
|
|
369
375
|
isOlderThan(n, unit, now) {
|
|
370
376
|
return this.isBefore(LocalTime.of(now ?? new Date()).add(-n, unit));
|
|
371
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Checks if this localTime is younger than "now" by X units.
|
|
380
|
+
*
|
|
381
|
+
* Example:
|
|
382
|
+
*
|
|
383
|
+
* localTime(expirationDate).isYoungerThan(5, 'day')
|
|
384
|
+
*
|
|
385
|
+
* Third argument allows to override "now".
|
|
386
|
+
*/
|
|
387
|
+
isYoungerThan(n, unit, now) {
|
|
388
|
+
return !this.isOlderThan(n, unit, now);
|
|
389
|
+
}
|
|
372
390
|
/**
|
|
373
391
|
* Returns 1 if this > d
|
|
374
392
|
* returns 0 if they are equal
|
|
@@ -188,6 +188,18 @@ export class LocalDate {
|
|
|
188
188
|
isOlderThan(n, unit, today) {
|
|
189
189
|
return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit));
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Checks if this localDate is younger than "today" by X units.
|
|
193
|
+
*
|
|
194
|
+
* Example:
|
|
195
|
+
*
|
|
196
|
+
* localDate(expirationDate).isYoungerThan(5, 'day')
|
|
197
|
+
*
|
|
198
|
+
* Third argument allows to override "today".
|
|
199
|
+
*/
|
|
200
|
+
isYoungerThan(n, unit, today) {
|
|
201
|
+
return !this.isOlderThan(n, unit, today);
|
|
202
|
+
}
|
|
191
203
|
/**
|
|
192
204
|
* Returns 1 if this > d
|
|
193
205
|
* returns 0 if they are equal
|
|
@@ -337,6 +349,12 @@ export class LocalDate {
|
|
|
337
349
|
subtract(num, unit, mutate = false) {
|
|
338
350
|
return this.add(-num, unit, mutate);
|
|
339
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Alias to subtract
|
|
354
|
+
*/
|
|
355
|
+
minus(num, unit, mutate = false) {
|
|
356
|
+
return this.add(-num, unit, mutate);
|
|
357
|
+
}
|
|
340
358
|
startOf(unit) {
|
|
341
359
|
if (unit === 'day')
|
|
342
360
|
return this;
|
|
@@ -212,6 +212,12 @@ export class LocalTime {
|
|
|
212
212
|
subtract(num, unit, mutate = false) {
|
|
213
213
|
return this.add(num * -1, unit, mutate);
|
|
214
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Alias to subtract.
|
|
217
|
+
*/
|
|
218
|
+
minus(num, unit, mutate = false) {
|
|
219
|
+
return this.add(num * -1, unit, mutate);
|
|
220
|
+
}
|
|
215
221
|
absDiff(other, unit) {
|
|
216
222
|
return Math.abs(this.diff(other, unit));
|
|
217
223
|
}
|
|
@@ -367,6 +373,18 @@ export class LocalTime {
|
|
|
367
373
|
isOlderThan(n, unit, now) {
|
|
368
374
|
return this.isBefore(LocalTime.of(now !== null && now !== void 0 ? now : new Date()).add(-n, unit));
|
|
369
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Checks if this localTime is younger than "now" by X units.
|
|
378
|
+
*
|
|
379
|
+
* Example:
|
|
380
|
+
*
|
|
381
|
+
* localTime(expirationDate).isYoungerThan(5, 'day')
|
|
382
|
+
*
|
|
383
|
+
* Third argument allows to override "now".
|
|
384
|
+
*/
|
|
385
|
+
isYoungerThan(n, unit, now) {
|
|
386
|
+
return !this.isOlderThan(n, unit, now);
|
|
387
|
+
}
|
|
370
388
|
/**
|
|
371
389
|
* Returns 1 if this > d
|
|
372
390
|
* returns 0 if they are equal
|
package/package.json
CHANGED
|
@@ -253,6 +253,19 @@ export class LocalDate {
|
|
|
253
253
|
return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit))
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Checks if this localDate is younger than "today" by X units.
|
|
258
|
+
*
|
|
259
|
+
* Example:
|
|
260
|
+
*
|
|
261
|
+
* localDate(expirationDate).isYoungerThan(5, 'day')
|
|
262
|
+
*
|
|
263
|
+
* Third argument allows to override "today".
|
|
264
|
+
*/
|
|
265
|
+
isYoungerThan(n: number, unit: LocalDateUnitStrict, today?: LocalDateInput): boolean {
|
|
266
|
+
return !this.isOlderThan(n, unit, today)
|
|
267
|
+
}
|
|
268
|
+
|
|
256
269
|
/**
|
|
257
270
|
* Returns 1 if this > d
|
|
258
271
|
* returns 0 if they are equal
|
|
@@ -419,6 +432,13 @@ export class LocalDate {
|
|
|
419
432
|
return this.add(-num, unit, mutate)
|
|
420
433
|
}
|
|
421
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Alias to subtract
|
|
437
|
+
*/
|
|
438
|
+
minus(num: number, unit: LocalDateUnit, mutate = false): LocalDate {
|
|
439
|
+
return this.add(-num, unit, mutate)
|
|
440
|
+
}
|
|
441
|
+
|
|
422
442
|
startOf(unit: LocalDateUnitStrict): LocalDate {
|
|
423
443
|
if (unit === 'day') return this
|
|
424
444
|
if (unit === 'month') return LocalDate.create(this.$year, this.$month, 1)
|
|
@@ -284,6 +284,13 @@ export class LocalTime {
|
|
|
284
284
|
return this.add(num * -1, unit, mutate)
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Alias to subtract.
|
|
289
|
+
*/
|
|
290
|
+
minus(num: number, unit: LocalTimeUnit, mutate = false): LocalTime {
|
|
291
|
+
return this.add(num * -1, unit, mutate)
|
|
292
|
+
}
|
|
293
|
+
|
|
287
294
|
absDiff(other: LocalTimeInput, unit: LocalTimeUnit): number {
|
|
288
295
|
return Math.abs(this.diff(other, unit))
|
|
289
296
|
}
|
|
@@ -453,6 +460,19 @@ export class LocalTime {
|
|
|
453
460
|
return this.isBefore(LocalTime.of(now ?? new Date()).add(-n, unit))
|
|
454
461
|
}
|
|
455
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Checks if this localTime is younger than "now" by X units.
|
|
465
|
+
*
|
|
466
|
+
* Example:
|
|
467
|
+
*
|
|
468
|
+
* localTime(expirationDate).isYoungerThan(5, 'day')
|
|
469
|
+
*
|
|
470
|
+
* Third argument allows to override "now".
|
|
471
|
+
*/
|
|
472
|
+
isYoungerThan(n: number, unit: LocalTimeUnit, now?: LocalTimeInput): boolean {
|
|
473
|
+
return !this.isOlderThan(n, unit, now)
|
|
474
|
+
}
|
|
475
|
+
|
|
456
476
|
/**
|
|
457
477
|
* Returns 1 if this > d
|
|
458
478
|
* returns 0 if they are equal
|