@naturalcycles/js-lib 15.47.3 → 15.48.1
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 +5 -5
- package/dist/datetime/localDate.js +6 -6
- package/dist/datetime/localTime.d.ts +5 -2
- package/dist/datetime/localTime.js +6 -3
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
- package/src/datetime/localDate.ts +8 -8
- package/src/datetime/localTime.ts +8 -5
- package/src/types.ts +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Iterable2 } from '../iter/iterable2.js';
|
|
2
|
-
import type { Inclusiveness, IsoDate, IsoDateTime,
|
|
2
|
+
import type { Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MutateOptions, SortOptions, UnixTimestamp, UnixTimestampMillis } from '../types.js';
|
|
3
3
|
import type { DateObject, ISODayOfWeek, LocalTime } from './localTime.js';
|
|
4
4
|
export type LocalDateUnit = LocalDateUnitStrict | 'week';
|
|
5
5
|
export type LocalDateUnitStrict = 'year' | 'month' | 'day';
|
|
@@ -132,6 +132,10 @@ export declare class LocalDate {
|
|
|
132
132
|
* Returns e.g: `1984-06-21`
|
|
133
133
|
*/
|
|
134
134
|
toISODate(): IsoDate;
|
|
135
|
+
/**
|
|
136
|
+
* Returns e.g: `1984-06`
|
|
137
|
+
*/
|
|
138
|
+
toISOMonth(): IsoMonth;
|
|
135
139
|
/**
|
|
136
140
|
* Returns e.g: `1984-06-21T00:00:00`
|
|
137
141
|
* Hours, minutes and seconds are 0.
|
|
@@ -147,10 +151,6 @@ export declare class LocalDate {
|
|
|
147
151
|
* Returns e.g: `19840621`
|
|
148
152
|
*/
|
|
149
153
|
toStringCompact(): string;
|
|
150
|
-
/**
|
|
151
|
-
* Returns e.g: `1984-06`
|
|
152
|
-
*/
|
|
153
|
-
toMonthId(): MonthId;
|
|
154
154
|
/**
|
|
155
155
|
* Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
|
|
156
156
|
*/
|
|
@@ -401,6 +401,12 @@ export class LocalDate {
|
|
|
401
401
|
String(this.day).padStart(2, '0'),
|
|
402
402
|
].join('-');
|
|
403
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Returns e.g: `1984-06`
|
|
406
|
+
*/
|
|
407
|
+
toISOMonth() {
|
|
408
|
+
return this.toISODate().slice(0, 7);
|
|
409
|
+
}
|
|
404
410
|
/**
|
|
405
411
|
* Returns e.g: `1984-06-21T00:00:00`
|
|
406
412
|
* Hours, minutes and seconds are 0.
|
|
@@ -428,12 +434,6 @@ export class LocalDate {
|
|
|
428
434
|
String(this.day).padStart(2, '0'),
|
|
429
435
|
].join('');
|
|
430
436
|
}
|
|
431
|
-
/**
|
|
432
|
-
* Returns e.g: `1984-06`
|
|
433
|
-
*/
|
|
434
|
-
toMonthId() {
|
|
435
|
-
return this.toISODate().slice(0, 7);
|
|
436
|
-
}
|
|
437
437
|
/**
|
|
438
438
|
* Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
|
|
439
439
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime,
|
|
1
|
+
import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MutateOptions, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types.js';
|
|
2
2
|
import type { LocalDate } from './localDate.js';
|
|
3
3
|
import { WallTime } from './wallTime.js';
|
|
4
4
|
export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
@@ -216,6 +216,10 @@ export declare class LocalTime {
|
|
|
216
216
|
* Returns e.g: `1984-06-21`, only the date part of DateTime
|
|
217
217
|
*/
|
|
218
218
|
toISODate(): IsoDate;
|
|
219
|
+
/**
|
|
220
|
+
* Returns e.g: `1984-06`
|
|
221
|
+
*/
|
|
222
|
+
toISOMonth(): IsoMonth;
|
|
219
223
|
/**
|
|
220
224
|
* Returns e.g: `17:03:15` (or `17:03` with seconds=false)
|
|
221
225
|
*/
|
|
@@ -227,7 +231,6 @@ export declare class LocalTime {
|
|
|
227
231
|
toStringCompact(seconds?: boolean): string;
|
|
228
232
|
toString(): IsoDateTime;
|
|
229
233
|
toJSON(): UnixTimestamp;
|
|
230
|
-
toMonthId(): MonthId;
|
|
231
234
|
format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string;
|
|
232
235
|
}
|
|
233
236
|
declare class LocalTimeFactory {
|
|
@@ -589,6 +589,12 @@ export class LocalTime {
|
|
|
589
589
|
// !! Not using toISOString(), as it returns time in UTC, not in local timezone (unexpected!)
|
|
590
590
|
// return this.$date.toISOString().slice(0, 10)
|
|
591
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Returns e.g: `1984-06`
|
|
594
|
+
*/
|
|
595
|
+
toISOMonth() {
|
|
596
|
+
return this.toISODate().slice(0, 7);
|
|
597
|
+
}
|
|
592
598
|
/**
|
|
593
599
|
* Returns e.g: `17:03:15` (or `17:03` with seconds=false)
|
|
594
600
|
*/
|
|
@@ -628,9 +634,6 @@ export class LocalTime {
|
|
|
628
634
|
toJSON() {
|
|
629
635
|
return this.unix;
|
|
630
636
|
}
|
|
631
|
-
toMonthId() {
|
|
632
|
-
return this.toISODate().slice(0, 7);
|
|
633
|
-
}
|
|
634
637
|
format(fmt) {
|
|
635
638
|
if (fmt instanceof Intl.DateTimeFormat) {
|
|
636
639
|
return fmt.format(this.$date);
|
package/dist/types.d.ts
CHANGED
|
@@ -191,12 +191,12 @@ export type IsoDate = Branded<string, 'IsoDate'>;
|
|
|
191
191
|
*/
|
|
192
192
|
export type IsoDateTime = Branded<string, 'IsoDateTime'>;
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
194
|
+
* ISO 8601 month (YYYY-MM).
|
|
195
|
+
* Branded type.
|
|
196
196
|
*
|
|
197
|
-
* @example '
|
|
197
|
+
* @example '2019-06'
|
|
198
198
|
*/
|
|
199
|
-
export type
|
|
199
|
+
export type IsoMonth = Branded<string, 'IsoMonth'>;
|
|
200
200
|
/**
|
|
201
201
|
* Identifies IANA timezone name.
|
|
202
202
|
* Branded type.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
Inclusiveness,
|
|
5
5
|
IsoDate,
|
|
6
6
|
IsoDateTime,
|
|
7
|
-
|
|
7
|
+
IsoMonth,
|
|
8
8
|
MutateOptions,
|
|
9
9
|
SortOptions,
|
|
10
10
|
UnixTimestamp,
|
|
@@ -474,6 +474,13 @@ export class LocalDate {
|
|
|
474
474
|
].join('-') as IsoDate
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Returns e.g: `1984-06`
|
|
479
|
+
*/
|
|
480
|
+
toISOMonth(): IsoMonth {
|
|
481
|
+
return this.toISODate().slice(0, 7) as IsoMonth
|
|
482
|
+
}
|
|
483
|
+
|
|
477
484
|
/**
|
|
478
485
|
* Returns e.g: `1984-06-21T00:00:00`
|
|
479
486
|
* Hours, minutes and seconds are 0.
|
|
@@ -505,13 +512,6 @@ export class LocalDate {
|
|
|
505
512
|
].join('')
|
|
506
513
|
}
|
|
507
514
|
|
|
508
|
-
/**
|
|
509
|
-
* Returns e.g: `1984-06`
|
|
510
|
-
*/
|
|
511
|
-
toMonthId(): MonthId {
|
|
512
|
-
return this.toISODate().slice(0, 7)
|
|
513
|
-
}
|
|
514
|
-
|
|
515
515
|
/**
|
|
516
516
|
* Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
|
|
517
517
|
*/
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
Inclusiveness,
|
|
5
5
|
IsoDate,
|
|
6
6
|
IsoDateTime,
|
|
7
|
-
|
|
7
|
+
IsoMonth,
|
|
8
8
|
MutateOptions,
|
|
9
9
|
NumberOfHours,
|
|
10
10
|
NumberOfMinutes,
|
|
@@ -710,6 +710,13 @@ export class LocalTime {
|
|
|
710
710
|
// return this.$date.toISOString().slice(0, 10)
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
+
/**
|
|
714
|
+
* Returns e.g: `1984-06`
|
|
715
|
+
*/
|
|
716
|
+
toISOMonth(): IsoMonth {
|
|
717
|
+
return this.toISODate().slice(0, 7) as IsoMonth
|
|
718
|
+
}
|
|
719
|
+
|
|
713
720
|
/**
|
|
714
721
|
* Returns e.g: `17:03:15` (or `17:03` with seconds=false)
|
|
715
722
|
*/
|
|
@@ -757,10 +764,6 @@ export class LocalTime {
|
|
|
757
764
|
return this.unix
|
|
758
765
|
}
|
|
759
766
|
|
|
760
|
-
toMonthId(): MonthId {
|
|
761
|
-
return this.toISODate().slice(0, 7)
|
|
762
|
-
}
|
|
763
|
-
|
|
764
767
|
format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string {
|
|
765
768
|
if (fmt instanceof Intl.DateTimeFormat) {
|
|
766
769
|
return fmt.format(this.$date)
|
package/src/types.ts
CHANGED
|
@@ -247,12 +247,12 @@ export type IsoDate = Branded<string, 'IsoDate'>
|
|
|
247
247
|
export type IsoDateTime = Branded<string, 'IsoDateTime'>
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
250
|
+
* ISO 8601 month (YYYY-MM).
|
|
251
|
+
* Branded type.
|
|
252
252
|
*
|
|
253
|
-
* @example '
|
|
253
|
+
* @example '2019-06'
|
|
254
254
|
*/
|
|
255
|
-
export type
|
|
255
|
+
export type IsoMonth = Branded<string, 'IsoMonth'>
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
258
|
* Identifies IANA timezone name.
|