@naturalcycles/js-lib 14.243.1 → 14.244.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.
@@ -15,6 +15,7 @@ export type LocalTimeInput = LocalTime | Date | IsoDateTimeString | UnixTimestam
15
15
  export type LocalTimeInputNullable = LocalTimeInput | null | undefined;
16
16
  export type LocalTimeFormatter = (ld: LocalTime) => string;
17
17
  export type DateTimeObject = DateObject & TimeObject;
18
+ export type DateTimeObjectInput = DateObject & Partial<TimeObject>;
18
19
  export interface DateObject {
19
20
  year: number;
20
21
  month: number;
@@ -32,12 +33,12 @@ export declare class LocalTime {
32
33
  * Returns [cloned] LocalTime that is based on the same unixtimestamp, but in UTC timezone.
33
34
  * Opposite of `.local()` method.
34
35
  */
35
- utc(): LocalTime;
36
+ toUTC(): LocalTime;
36
37
  /**
37
38
  * Returns [cloned] LocalTime that is based on the same unixtimestamp, but in local timezone.
38
39
  * Opposite of `.utc()` method.
39
40
  */
40
- local(): LocalTime;
41
+ toLocal(): LocalTime;
41
42
  /**
42
43
  * Returns [cloned] fake LocalTime that has yyyy-mm-dd hh:mm:ss in the provided timezone.
43
44
  * It is a fake LocalTime in a sense that it's timezone is not real.
@@ -85,25 +86,25 @@ export declare class LocalTime {
85
86
  getUTCOffsetString(tz: string): string;
86
87
  get(unit: LocalTimeUnit): number;
87
88
  set(unit: LocalTimeUnit, v: number, mutate?: boolean): LocalTime;
88
- year(): number;
89
- year(v: number): LocalTime;
90
- month(): number;
91
- month(v: number): LocalTime;
92
- week(): number;
93
- week(v: number): LocalTime;
94
- day(): number;
95
- day(v: number): LocalTime;
89
+ get year(): number;
90
+ setYear(v: number): LocalTime;
91
+ get month(): number;
92
+ setMonth(v: number): LocalTime;
93
+ get week(): number;
94
+ setWeek(v: number): LocalTime;
95
+ get day(): number;
96
+ setDay(v: number): LocalTime;
97
+ get hour(): number;
98
+ setHour(v: number): LocalTime;
99
+ get minute(): number;
100
+ setMinute(v: number): LocalTime;
101
+ get second(): number;
102
+ setSecond(v: number): LocalTime;
96
103
  /**
97
104
  * Based on ISO: 1-7 is Mon-Sun.
98
105
  */
99
- dayOfWeek(): ISODayOfWeek;
100
- dayOfWeek(v: ISODayOfWeek): LocalTime;
101
- hour(): number;
102
- hour(v: number): LocalTime;
103
- minute(): number;
104
- minute(v: number): LocalTime;
105
- second(): number;
106
- second(v: number): LocalTime;
106
+ get dayOfWeek(): ISODayOfWeek;
107
+ setDayOfWeek(v: ISODayOfWeek): LocalTime;
107
108
  setComponents(c: Partial<DateTimeObject>, mutate?: boolean): LocalTime;
108
109
  plusSeconds(num: number): LocalTime;
109
110
  plusMinutes(num: number): LocalTime;
@@ -129,7 +130,7 @@ export declare class LocalTime {
129
130
  * Returns how many days are in the current month.
130
131
  * E.g 31 for January.
131
132
  */
132
- daysInMonth(): number;
133
+ get daysInMonth(): number;
133
134
  isSame(d: LocalTimeInput): boolean;
134
135
  isBefore(d: LocalTimeInput, inclusive?: boolean): boolean;
135
136
  isSameOrBefore(d: LocalTimeInput): boolean;
@@ -176,15 +177,15 @@ export declare class LocalTime {
176
177
  * returns 0 if they are equal
177
178
  * returns -1 if this < d
178
179
  */
179
- cmp(d: LocalTimeInput): -1 | 0 | 1;
180
- getDateTimeObject(): DateTimeObject;
181
- getDateObject(): DateObject;
182
- getTimeObject(): TimeObject;
183
- fromNow(now?: LocalTimeInput): string;
184
- getDate(): Date;
180
+ compare(d: LocalTimeInput): -1 | 0 | 1;
181
+ toDateTimeObject(): DateTimeObject;
182
+ toDateObject(): DateObject;
183
+ toTimeObject(): TimeObject;
184
+ toFromNowString(now?: LocalTimeInput): string;
185
+ toDate(): Date;
185
186
  clone(): LocalTime;
186
- unix(): UnixTimestampNumber;
187
- unixMillis(): UnixTimestampMillisNumber;
187
+ get unix(): UnixTimestampNumber;
188
+ get unixMillis(): UnixTimestampMillisNumber;
188
189
  valueOf(): UnixTimestampNumber;
189
190
  toLocalDate(): LocalDate;
190
191
  /**
@@ -216,20 +217,26 @@ export declare class LocalTime {
216
217
  }
217
218
  declare class LocalTimeFactory {
218
219
  /**
219
- * Parses input String into LocalDate.
220
- * Input can already be a LocalDate - it is returned as-is in that case.
220
+ * Parses input String into LocalTime.
221
+ * Input can already be a LocalTime - it is returned as-is in that case.
221
222
  */
222
- of(d: LocalTimeInput): LocalTime;
223
+ from(input: LocalTimeInput): LocalTime;
224
+ fromDate(date: Date): LocalTime;
225
+ fromUnix(ts: UnixTimestampNumber): LocalTime;
223
226
  /**
224
227
  * Create LocalTime from unixTimestamp in milliseconds (not in seconds).
225
228
  */
226
- ofMillis(millis: UnixTimestampMillisNumber): LocalTime;
229
+ fromMillis(millis: UnixTimestampMillisNumber): LocalTime;
227
230
  /**
228
231
  * Returns null if invalid
229
232
  */
230
- parseOrNull(d: LocalTimeInputNullable): LocalTime | null;
233
+ fromOrNull(d: LocalTimeInputNullable): LocalTime | null;
234
+ fromStringOrNull(s: string | undefined | null): LocalTime | null;
235
+ fromDateTimeObject(input: DateTimeObjectInput): LocalTime;
231
236
  private parseStringToDateOrNull;
232
- isValid(d: LocalTimeInputNullable): boolean;
237
+ isValid(input: LocalTimeInputNullable): boolean;
238
+ isValidString(isoString: string | undefined | null): boolean;
239
+ private assertNotNull;
233
240
  /**
234
241
  * Returns the IANA timezone e.g `Europe/Stockholm`.
235
242
  * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
@@ -249,15 +256,11 @@ declare class LocalTimeFactory {
249
256
  *
250
257
  * `localTime` function will instead return LocalTime of `now` for falsy input.
251
258
  */
252
- orUndefined(d: LocalTimeInputNullable): LocalTime | undefined;
259
+ orUndefined(input: LocalTimeInputNullable): LocalTime | undefined;
253
260
  /**
254
261
  * Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
255
262
  */
256
- orNow(d: LocalTimeInputNullable): LocalTime;
257
- fromComponents(c: {
258
- year: number;
259
- month: number;
260
- } & Partial<DateTimeObject>): LocalTime;
263
+ orNow(input: LocalTimeInputNullable): LocalTime;
261
264
  sort(items: LocalTime[], dir?: SortDirection, mutate?: boolean): LocalTime[];
262
265
  minOrUndefined(items: LocalTimeInputNullable[]): LocalTime | undefined;
263
266
  min(items: LocalTimeInputNullable[]): LocalTime;
@@ -35,14 +35,14 @@ class LocalTime {
35
35
  * Returns [cloned] LocalTime that is based on the same unixtimestamp, but in UTC timezone.
36
36
  * Opposite of `.local()` method.
37
37
  */
38
- utc() {
38
+ toUTC() {
39
39
  return new LocalTime(new Date(this.$date.toISOString()));
40
40
  }
41
41
  /**
42
42
  * Returns [cloned] LocalTime that is based on the same unixtimestamp, but in local timezone.
43
43
  * Opposite of `.utc()` method.
44
44
  */
45
- local() {
45
+ toLocal() {
46
46
  return new LocalTime(new Date(this.$date.getTime()));
47
47
  }
48
48
  /**
@@ -164,34 +164,58 @@ class LocalTime {
164
164
  }
165
165
  return t;
166
166
  }
167
- year(v) {
168
- return v === undefined ? this.get('year') : this.set('year', v);
167
+ get year() {
168
+ return this.$date.getFullYear();
169
169
  }
170
- month(v) {
171
- return v === undefined ? this.get('month') : this.set('month', v);
170
+ setYear(v) {
171
+ return this.set('year', v);
172
172
  }
173
- week(v) {
174
- return v === undefined ? getWeek(this.$date) : this.set('week', v);
173
+ get month() {
174
+ return this.$date.getMonth() + 1;
175
175
  }
176
- day(v) {
177
- return v === undefined ? this.get('day') : this.set('day', v);
176
+ setMonth(v) {
177
+ return this.set('month', v);
178
178
  }
179
- dayOfWeek(v) {
180
- const dow = (this.$date.getDay() || 7);
181
- if (v === undefined) {
182
- return dow;
183
- }
184
- (0, assert_1._assert)(VALID_DAYS_OF_WEEK.has(v), `Invalid dayOfWeek: ${v}`);
185
- return this.plus(v - dow, 'day');
179
+ get week() {
180
+ return getWeek(this.$date);
181
+ }
182
+ setWeek(v) {
183
+ return this.set('week', v);
184
+ }
185
+ get day() {
186
+ return this.$date.getDate();
186
187
  }
187
- hour(v) {
188
- return v === undefined ? this.get('hour') : this.set('hour', v);
188
+ setDay(v) {
189
+ return this.set('day', v);
189
190
  }
190
- minute(v) {
191
- return v === undefined ? this.get('minute') : this.set('minute', v);
191
+ get hour() {
192
+ return this.$date.getHours();
192
193
  }
193
- second(v) {
194
- return v === undefined ? this.get('second') : this.set('second', v);
194
+ setHour(v) {
195
+ return this.set('hour', v);
196
+ }
197
+ get minute() {
198
+ return this.$date.getMinutes();
199
+ }
200
+ setMinute(v) {
201
+ return this.set('minute', v);
202
+ }
203
+ get second() {
204
+ return this.$date.getSeconds();
205
+ }
206
+ setSecond(v) {
207
+ return this.set('second', v);
208
+ }
209
+ /**
210
+ * Based on ISO: 1-7 is Mon-Sun.
211
+ */
212
+ get dayOfWeek() {
213
+ return (this.$date.getDay() || 7);
214
+ }
215
+ setDayOfWeek(v) {
216
+ (0, assert_1._assert)(VALID_DAYS_OF_WEEK.has(v), `Invalid dayOfWeek: ${v}`);
217
+ const dow = this.$date.getDay() || 7;
218
+ return this.plus(v - dow, 'day');
195
219
  }
196
220
  setComponents(c, mutate = false) {
197
221
  const d = mutate ? this.$date : new Date(this.$date);
@@ -259,7 +283,7 @@ class LocalTime {
259
283
  }
260
284
  if (unit === 'year' || unit === 'month') {
261
285
  const d = addMonths(this.$date, unit === 'month' ? num : num * 12, mutate);
262
- return mutate ? this : exports.localTime.of(d);
286
+ return mutate ? this : exports.localTime.from(d);
263
287
  }
264
288
  return this.set(unit, this.get(unit) + num, mutate);
265
289
  }
@@ -270,7 +294,7 @@ class LocalTime {
270
294
  return Math.abs(this.diff(other, unit));
271
295
  }
272
296
  diff(other, unit) {
273
- const date2 = exports.localTime.of(other).$date;
297
+ const date2 = exports.localTime.from(other).$date;
274
298
  const secDiff = (this.$date.valueOf() - date2.valueOf()) / 1000;
275
299
  if (!secDiff)
276
300
  return 0;
@@ -358,32 +382,32 @@ class LocalTime {
358
382
  * Returns how many days are in the current month.
359
383
  * E.g 31 for January.
360
384
  */
361
- daysInMonth() {
385
+ get daysInMonth() {
362
386
  return localDate_1.localDate.getMonthLength(this.$date.getFullYear(), this.$date.getMonth() + 1);
363
387
  }
364
388
  isSame(d) {
365
- return this.cmp(d) === 0;
389
+ return this.compare(d) === 0;
366
390
  }
367
391
  isBefore(d, inclusive = false) {
368
- const r = this.cmp(d);
392
+ const r = this.compare(d);
369
393
  return r === -1 || (r === 0 && inclusive);
370
394
  }
371
395
  isSameOrBefore(d) {
372
- return this.cmp(d) <= 0;
396
+ return this.compare(d) <= 0;
373
397
  }
374
398
  isAfter(d, inclusive = false) {
375
- const r = this.cmp(d);
399
+ const r = this.compare(d);
376
400
  return r === 1 || (r === 0 && inclusive);
377
401
  }
378
402
  isSameOrAfter(d) {
379
- return this.cmp(d) >= 0;
403
+ return this.compare(d) >= 0;
380
404
  }
381
405
  isBetween(min, max, incl = '[)') {
382
- let r = this.cmp(min);
406
+ let r = this.compare(min);
383
407
  // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
384
408
  if (r < 0 || (r === 0 && incl[0] === '('))
385
409
  return false;
386
- r = this.cmp(max);
410
+ r = this.compare(max);
387
411
  if (r > 0 || (r === 0 && incl[1] === ')'))
388
412
  return false;
389
413
  return true;
@@ -398,13 +422,13 @@ class LocalTime {
398
422
  * Third argument allows to override "now".
399
423
  */
400
424
  isOlderThan(n, unit, now) {
401
- return this.isBefore(exports.localTime.of(now ?? new Date()).plus(-n, unit));
425
+ return this.isBefore(exports.localTime.from(now ?? new Date()).plus(-n, unit));
402
426
  }
403
427
  /**
404
428
  * Checks if this localTime is same or older (<=) than "now" by X units.
405
429
  */
406
430
  isSameOrOlderThan(n, unit, now) {
407
- return this.isSameOrBefore(exports.localTime.of(now ?? new Date()).plus(-n, unit));
431
+ return this.isSameOrBefore(exports.localTime.from(now ?? new Date()).plus(-n, unit));
408
432
  }
409
433
  /**
410
434
  * Checks if this localTime is younger (>) than "now" by X units.
@@ -416,13 +440,13 @@ class LocalTime {
416
440
  * Third argument allows to override "now".
417
441
  */
418
442
  isYoungerThan(n, unit, now) {
419
- return this.isAfter(exports.localTime.of(now ?? new Date()).plus(-n, unit));
443
+ return this.isAfter(exports.localTime.from(now ?? new Date()).plus(-n, unit));
420
444
  }
421
445
  /**
422
446
  * Checks if this localTime is same or younger (>=) than "now" by X units.
423
447
  */
424
448
  isSameOrYoungerThan(n, unit, now) {
425
- return this.isSameOrAfter(exports.localTime.of(now ?? new Date()).plus(-n, unit));
449
+ return this.isSameOrAfter(exports.localTime.from(now ?? new Date()).plus(-n, unit));
426
450
  }
427
451
  getAgeInYears(now) {
428
452
  return this.getAgeIn('year', now);
@@ -443,42 +467,42 @@ class LocalTime {
443
467
  return this.getAgeIn('second', now);
444
468
  }
445
469
  getAgeIn(unit, now) {
446
- return exports.localTime.of(now ?? new Date()).diff(this, unit);
470
+ return exports.localTime.from(now ?? new Date()).diff(this, unit);
447
471
  }
448
472
  /**
449
473
  * Returns 1 if this > d
450
474
  * returns 0 if they are equal
451
475
  * returns -1 if this < d
452
476
  */
453
- cmp(d) {
477
+ compare(d) {
454
478
  const t1 = this.$date.valueOf();
455
- const t2 = exports.localTime.of(d).$date.valueOf();
479
+ const t2 = exports.localTime.from(d).$date.valueOf();
456
480
  if (t1 === t2)
457
481
  return 0;
458
482
  return t1 < t2 ? -1 : 1;
459
483
  }
460
- getDateTimeObject() {
484
+ toDateTimeObject() {
461
485
  return {
462
- ...this.getDateObject(),
463
- ...this.getTimeObject(),
486
+ ...this.toDateObject(),
487
+ ...this.toTimeObject(),
464
488
  };
465
489
  }
466
- getDateObject() {
490
+ toDateObject() {
467
491
  return {
468
492
  year: this.$date.getFullYear(),
469
493
  month: this.$date.getMonth() + 1,
470
494
  day: this.$date.getDate(),
471
495
  };
472
496
  }
473
- getTimeObject() {
497
+ toTimeObject() {
474
498
  return {
475
499
  hour: this.$date.getHours(),
476
500
  minute: this.$date.getMinutes(),
477
501
  second: this.$date.getSeconds(),
478
502
  };
479
503
  }
480
- fromNow(now = new Date()) {
481
- const msDiff = exports.localTime.of(now).$date.valueOf() - this.$date.valueOf();
504
+ toFromNowString(now = new Date()) {
505
+ const msDiff = exports.localTime.from(now).$date.valueOf() - this.$date.valueOf();
482
506
  if (msDiff === 0)
483
507
  return 'now';
484
508
  if (msDiff >= 0) {
@@ -486,16 +510,16 @@ class LocalTime {
486
510
  }
487
511
  return `in ${(0, time_util_1._ms)(msDiff * -1)}`;
488
512
  }
489
- getDate() {
513
+ toDate() {
490
514
  return this.$date;
491
515
  }
492
516
  clone() {
493
517
  return new LocalTime(new Date(this.$date));
494
518
  }
495
- unix() {
519
+ get unix() {
496
520
  return Math.floor(this.$date.valueOf() / 1000);
497
521
  }
498
- unixMillis() {
522
+ get unixMillis() {
499
523
  return this.$date.valueOf();
500
524
  }
501
525
  valueOf() {
@@ -527,7 +551,7 @@ class LocalTime {
527
551
  * Returns e.g: `1984-06-21`, only the date part of DateTime
528
552
  */
529
553
  toISODate() {
530
- const { year, month, day } = this.getDateObject();
554
+ const { year, month, day } = this.toDateObject();
531
555
  return [
532
556
  String(year).padStart(4, '0'),
533
557
  String(month).padStart(2, '0'),
@@ -540,7 +564,7 @@ class LocalTime {
540
564
  * Returns e.g: `17:03:15` (or `17:03` with seconds=false)
541
565
  */
542
566
  toISOTime(seconds = true) {
543
- const { hour, minute, second } = this.getTimeObject();
567
+ const { hour, minute, second } = this.toTimeObject();
544
568
  return [
545
569
  String(hour).padStart(2, '0'),
546
570
  String(minute).padStart(2, '0'),
@@ -555,7 +579,7 @@ class LocalTime {
555
579
  * Returns e.g: `19840621_1705`
556
580
  */
557
581
  toStringCompact(seconds = false) {
558
- const { year, month, day, hour, minute, second } = this.getDateTimeObject();
582
+ const { year, month, day, hour, minute, second } = this.toDateTimeObject();
559
583
  return [
560
584
  String(year).padStart(4, '0'),
561
585
  String(month).padStart(2, '0'),
@@ -570,7 +594,7 @@ class LocalTime {
570
594
  return this.toISODateTime();
571
595
  }
572
596
  toJSON() {
573
- return this.unix();
597
+ return this.unix;
574
598
  }
575
599
  toMonthId() {
576
600
  return this.toISODate().slice(0, 7);
@@ -585,51 +609,56 @@ class LocalTime {
585
609
  exports.LocalTime = LocalTime;
586
610
  class LocalTimeFactory {
587
611
  /**
588
- * Parses input String into LocalDate.
589
- * Input can already be a LocalDate - it is returned as-is in that case.
612
+ * Parses input String into LocalTime.
613
+ * Input can already be a LocalTime - it is returned as-is in that case.
590
614
  */
591
- of(d) {
592
- const t = this.parseOrNull(d);
593
- (0, assert_1._assert)(t !== null, `Cannot parse "${d}" into LocalTime`, {
594
- input: d,
595
- });
596
- return t;
615
+ from(input) {
616
+ const lt = this.fromOrNull(input);
617
+ this.assertNotNull(lt, input);
618
+ return lt;
619
+ }
620
+ fromDate(date) {
621
+ return new LocalTime(date);
622
+ }
623
+ fromUnix(ts) {
624
+ return new LocalTime(new Date(ts * 1000));
597
625
  }
598
626
  /**
599
627
  * Create LocalTime from unixTimestamp in milliseconds (not in seconds).
600
628
  */
601
- ofMillis(millis) {
602
- return this.of(new Date(millis));
629
+ fromMillis(millis) {
630
+ return new LocalTime(new Date(millis));
603
631
  }
604
632
  /**
605
633
  * Returns null if invalid
606
634
  */
607
- parseOrNull(d) {
635
+ fromOrNull(d) {
608
636
  if (d instanceof LocalTime)
609
637
  return d;
610
- let date;
611
638
  if (d instanceof Date) {
612
- date = d;
639
+ return new LocalTime(d);
613
640
  }
614
- else if (typeof d === 'number') {
615
- date = new Date(d * 1000);
641
+ if (typeof d === 'number') {
642
+ return new LocalTime(new Date(d * 1000));
616
643
  }
617
- else if (!d) {
618
- // This check is after checking the number, to support `0`
619
- return null;
620
- }
621
- else if (typeof d !== 'string') {
622
- // unexpected type, e.g Function or something
623
- return null;
624
- }
625
- else {
626
- date = this.parseStringToDateOrNull(d);
627
- if (date === null)
628
- return null;
644
+ if (typeof d === 'string') {
645
+ return this.fromStringOrNull(d);
629
646
  }
630
- return new LocalTime(date);
647
+ // This check is after checking the number, to support `0`
648
+ // unexpected type, e.g Function or something
649
+ return null;
650
+ }
651
+ fromStringOrNull(s) {
652
+ const date = this.parseStringToDateOrNull(s);
653
+ return date ? new LocalTime(date) : null;
654
+ }
655
+ fromDateTimeObject(input) {
656
+ const { year, month, day = 1, hour = 0, minute = 0, second = 0 } = input;
657
+ return new LocalTime(new Date(year, month - 1, day, hour, minute, second));
631
658
  }
632
659
  parseStringToDateOrNull(s) {
660
+ if (!s)
661
+ return null;
633
662
  // Slicing removes the "timezone component", and makes the date "local"
634
663
  // e.g 2022-04-06T23:15:00+09:00
635
664
  // becomes 2022-04-06T23:15:00
@@ -681,8 +710,16 @@ class LocalTimeFactory {
681
710
  }
682
711
  return new Date(year, month - 1, day, hour || 0, minute || 0, second || 0, 0);
683
712
  }
684
- isValid(d) {
685
- return this.parseOrNull(d) !== null;
713
+ isValid(input) {
714
+ return this.fromOrNull(input) !== null;
715
+ }
716
+ isValidString(isoString) {
717
+ return this.fromStringOrNull(isoString) !== null;
718
+ }
719
+ assertNotNull(lt, input) {
720
+ (0, assert_1._assert)(lt !== null, `Cannot parse "${input}" into LocalTime`, {
721
+ input,
722
+ });
686
723
  }
687
724
  /**
688
725
  * Returns the IANA timezone e.g `Europe/Stockholm`.
@@ -709,17 +746,14 @@ class LocalTimeFactory {
709
746
  *
710
747
  * `localTime` function will instead return LocalTime of `now` for falsy input.
711
748
  */
712
- orUndefined(d) {
713
- return d ? this.of(d) : undefined;
749
+ orUndefined(input) {
750
+ return input || input === 0 ? this.from(input) : undefined;
714
751
  }
715
752
  /**
716
753
  * Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
717
754
  */
718
- orNow(d) {
719
- return d ? this.of(d) : this.now();
720
- }
721
- fromComponents(c) {
722
- return new LocalTime(new Date(c.year, c.month - 1, c.day || 1, c.hour || 0, c.minute || 0, c.second || 0));
755
+ orNow(input) {
756
+ return input || input === 0 ? this.from(input) : this.now();
723
757
  }
724
758
  sort(items, dir = 'asc', mutate = false) {
725
759
  const mod = dir === 'desc' ? -1 : 1;
@@ -738,7 +772,7 @@ class LocalTimeFactory {
738
772
  const items2 = items.filter(is_util_1._isTruthy);
739
773
  (0, assert_1._assert)(items2.length, 'localTime.min called on empty array');
740
774
  return items2
741
- .map(i => this.of(i))
775
+ .map(i => this.from(i))
742
776
  .reduce((min, item) => (min.$date.valueOf() <= item.$date.valueOf() ? min : item));
743
777
  }
744
778
  maxOrUndefined(items) {
@@ -748,7 +782,7 @@ class LocalTimeFactory {
748
782
  const items2 = items.filter(is_util_1._isTruthy);
749
783
  (0, assert_1._assert)(items2.length, 'localTime.max called on empty array');
750
784
  return items2
751
- .map(i => this.of(i))
785
+ .map(i => this.from(i))
752
786
  .reduce((max, item) => (max.$date.valueOf() >= item.$date.valueOf() ? max : item));
753
787
  }
754
788
  }
@@ -841,7 +875,7 @@ function differenceInMonths(a, b) {
841
875
  return -(wholeMonthDiff + ((b.getTime() - anchor) / (anchor2 - anchor)) * sign);
842
876
  }
843
877
  const localTimeFactory = new LocalTimeFactory();
844
- exports.localTime = localTimeFactory.of.bind(localTimeFactory);
878
+ exports.localTime = localTimeFactory.from.bind(localTimeFactory);
845
879
  // The line below is the blackest of black magic I have ever written in 2024.
846
880
  // And probably 2023 as well.
847
881
  Object.setPrototypeOf(exports.localTime, localTimeFactory);
@@ -14,7 +14,7 @@ class TimeInterval {
14
14
  this.$end = $end;
15
15
  }
16
16
  static of(start, end) {
17
- return new TimeInterval(localTime_1.localTime.of(start).unix(), localTime_1.localTime.of(end).unix());
17
+ return new TimeInterval(localTime_1.localTime.from(start).unix, localTime_1.localTime.from(end).unix);
18
18
  }
19
19
  get start() {
20
20
  return this.$start;
@@ -58,7 +58,7 @@ class TimeInterval {
58
58
  return this.cmp(d) >= 0;
59
59
  }
60
60
  includes(d, incl = '[)') {
61
- d = localTime_1.localTime.of(d).unix();
61
+ d = localTime_1.localTime.from(d).unix;
62
62
  // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
63
63
  if (d < this.$start || (d === this.$start && incl[0] === '('))
64
64
  return false;
@@ -4,11 +4,11 @@ exports.generateBuildInfoDev = generateBuildInfoDev;
4
4
  const localTime_1 = require("../datetime/localTime");
5
5
  function generateBuildInfoDev() {
6
6
  const now = localTime_1.localTime.now();
7
- const ts = now.unix();
7
+ const ts = now.unix;
8
8
  const rev = 'devRev';
9
9
  const branchName = 'devBranch';
10
10
  const repoName = 'devRepo';
11
- const tsCommit = now.unix();
11
+ const tsCommit = now.unix;
12
12
  const ver = [now.toStringCompact(), repoName, branchName, rev].join('_');
13
13
  return {
14
14
  ts,
@@ -60,7 +60,7 @@ export class DateInterval {
60
60
  */
61
61
  cmp(d) {
62
62
  d = DateInterval.parse(d);
63
- return this.start.cmp(d.start) || this.end.cmp(d.end);
63
+ return this.start.compare(d.start) || this.end.compare(d.end);
64
64
  }
65
65
  getDays(incl = '[]') {
66
66
  return localDate.range(this.start, this.end, incl, 1, 'day');