@naturalcycles/js-lib 14.185.0 → 14.186.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.
@@ -55,8 +55,10 @@ export declare class LocalDate {
55
55
  * Example:
56
56
  *
57
57
  * localDate(expirationDate).isOlderThan(5, 'day')
58
+ *
59
+ * Third argument allows to override "today".
58
60
  */
59
- isOlderThan(n: number, unit: LocalDateUnitStrict): boolean;
61
+ isOlderThan(n: number, unit: LocalDateUnitStrict, today?: LocalDateInput): boolean;
60
62
  /**
61
63
  * Returns 1 if this > d
62
64
  * returns 0 if they are equal
@@ -185,9 +185,11 @@ class LocalDate {
185
185
  * Example:
186
186
  *
187
187
  * localDate(expirationDate).isOlderThan(5, 'day')
188
+ *
189
+ * Third argument allows to override "today".
188
190
  */
189
- isOlderThan(n, unit) {
190
- return this.isBefore(LocalDate.today().add(-n, unit));
191
+ isOlderThan(n, unit, today) {
192
+ return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit));
191
193
  }
192
194
  /**
193
195
  * Returns 1 if this > d
@@ -93,8 +93,10 @@ export declare class LocalTime {
93
93
  * Example:
94
94
  *
95
95
  * localTime(expirationDate).isOlderThan(5, 'day')
96
+ *
97
+ * Third argument allows to override "now".
96
98
  */
97
- isOlderThan(n: number, unit: LocalTimeUnit): boolean;
99
+ isOlderThan(n: number, unit: LocalTimeUnit, now?: LocalTimeInput): boolean;
98
100
  /**
99
101
  * Returns 1 if this > d
100
102
  * returns 0 if they are equal
@@ -363,9 +363,11 @@ class LocalTime {
363
363
  * Example:
364
364
  *
365
365
  * localTime(expirationDate).isOlderThan(5, 'day')
366
+ *
367
+ * Third argument allows to override "now".
366
368
  */
367
- isOlderThan(n, unit) {
368
- return this.isBefore(LocalTime.now().add(-n, unit));
369
+ isOlderThan(n, unit, now) {
370
+ return this.isBefore(LocalTime.of(now ?? new Date()).add(-n, unit));
369
371
  }
370
372
  /**
371
373
  * Returns 1 if this > d
@@ -182,9 +182,11 @@ export class LocalDate {
182
182
  * Example:
183
183
  *
184
184
  * localDate(expirationDate).isOlderThan(5, 'day')
185
+ *
186
+ * Third argument allows to override "today".
185
187
  */
186
- isOlderThan(n, unit) {
187
- return this.isBefore(LocalDate.today().add(-n, unit));
188
+ isOlderThan(n, unit, today) {
189
+ return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit));
188
190
  }
189
191
  /**
190
192
  * Returns 1 if this > d
@@ -361,9 +361,11 @@ export class LocalTime {
361
361
  * Example:
362
362
  *
363
363
  * localTime(expirationDate).isOlderThan(5, 'day')
364
+ *
365
+ * Third argument allows to override "now".
364
366
  */
365
- isOlderThan(n, unit) {
366
- return this.isBefore(LocalTime.now().add(-n, unit));
367
+ isOlderThan(n, unit, now) {
368
+ return this.isBefore(LocalTime.of(now !== null && now !== void 0 ? now : new Date()).add(-n, unit));
367
369
  }
368
370
  /**
369
371
  * Returns 1 if this > d
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.185.0",
3
+ "version": "14.186.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -246,9 +246,11 @@ export class LocalDate {
246
246
  * Example:
247
247
  *
248
248
  * localDate(expirationDate).isOlderThan(5, 'day')
249
+ *
250
+ * Third argument allows to override "today".
249
251
  */
250
- isOlderThan(n: number, unit: LocalDateUnitStrict): boolean {
251
- return this.isBefore(LocalDate.today().add(-n, unit))
252
+ isOlderThan(n: number, unit: LocalDateUnitStrict, today?: LocalDateInput): boolean {
253
+ return this.isBefore(LocalDate.of(today || new Date()).add(-n, unit))
252
254
  }
253
255
 
254
256
  /**
@@ -446,9 +446,11 @@ export class LocalTime {
446
446
  * Example:
447
447
  *
448
448
  * localTime(expirationDate).isOlderThan(5, 'day')
449
+ *
450
+ * Third argument allows to override "now".
449
451
  */
450
- isOlderThan(n: number, unit: LocalTimeUnit): boolean {
451
- return this.isBefore(LocalTime.now().add(-n, unit))
452
+ isOlderThan(n: number, unit: LocalTimeUnit, now?: LocalTimeInput): boolean {
453
+ return this.isBefore(LocalTime.of(now ?? new Date()).add(-n, unit))
452
454
  }
453
455
 
454
456
  /**