@naturalcycles/js-lib 14.122.1 → 14.123.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.
@@ -91,7 +91,7 @@ export declare class LocalDate {
91
91
  unix(): UnixTimestampNumber;
92
92
  unixMillis(): UnixTimestampMillisNumber;
93
93
  toJSON(): IsoDateString;
94
- format(fmt: LocalDateFormatter): string;
94
+ format(fmt: Intl.DateTimeFormat | LocalDateFormatter): string;
95
95
  }
96
96
  /**
97
97
  * Shortcut wrapper around `LocalDate.parse` / `LocalDate.today`
@@ -404,6 +404,9 @@ class LocalDate {
404
404
  return this.toString();
405
405
  }
406
406
  format(fmt) {
407
+ if (fmt instanceof Intl.DateTimeFormat) {
408
+ return fmt.format(this.toDate());
409
+ }
407
410
  return fmt(this);
408
411
  }
409
412
  }
@@ -120,7 +120,7 @@ export declare class LocalTime {
120
120
  toStringCompact(seconds?: boolean): string;
121
121
  toString(): string;
122
122
  toJSON(): UnixTimestampNumber;
123
- format(fmt: LocalTimeFormatter): string;
123
+ format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string;
124
124
  }
125
125
  /**
126
126
  * Shortcut wrapper around `LocalDate.parse` / `LocalDate.today`
@@ -479,6 +479,9 @@ class LocalTime {
479
479
  return this.unix();
480
480
  }
481
481
  format(fmt) {
482
+ if (fmt instanceof Intl.DateTimeFormat) {
483
+ return fmt.format(this.$date);
484
+ }
482
485
  return fmt(this);
483
486
  }
484
487
  }
@@ -401,6 +401,9 @@ export class LocalDate {
401
401
  return this.toString();
402
402
  }
403
403
  format(fmt) {
404
+ if (fmt instanceof Intl.DateTimeFormat) {
405
+ return fmt.format(this.toDate());
406
+ }
404
407
  return fmt(this);
405
408
  }
406
409
  }
@@ -477,6 +477,9 @@ export class LocalTime {
477
477
  return this.unix();
478
478
  }
479
479
  format(fmt) {
480
+ if (fmt instanceof Intl.DateTimeFormat) {
481
+ return fmt.format(this.$date);
482
+ }
480
483
  return fmt(this);
481
484
  }
482
485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.122.1",
3
+ "version": "14.123.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -492,7 +492,11 @@ export class LocalDate {
492
492
  return this.toString()
493
493
  }
494
494
 
495
- format(fmt: LocalDateFormatter): string {
495
+ format(fmt: Intl.DateTimeFormat | LocalDateFormatter): string {
496
+ if (fmt instanceof Intl.DateTimeFormat) {
497
+ return fmt.format(this.toDate())
498
+ }
499
+
496
500
  return fmt(this)
497
501
  }
498
502
  }
@@ -590,7 +590,11 @@ export class LocalTime {
590
590
  return this.unix()
591
591
  }
592
592
 
593
- format(fmt: LocalTimeFormatter): string {
593
+ format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string {
594
+ if (fmt instanceof Intl.DateTimeFormat) {
595
+ return fmt.format(this.$date)
596
+ }
597
+
594
598
  return fmt(this)
595
599
  }
596
600
  }