@naturalcycles/js-lib 15.47.2 → 15.48.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 +6 -2
- package/dist/datetime/localDate.js +8 -2
- package/dist/datetime/localTime.d.ts +8 -1
- package/dist/datetime/localTime.js +10 -1
- package/dist/types.d.ts +8 -3
- package/package.json +2 -2
- package/src/datetime/localDate.ts +10 -2
- package/src/datetime/localTime.ts +12 -1
- package/src/types.ts +9 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Iterable2 } from '../iter/iterable2.js';
|
|
2
|
-
import type { Inclusiveness, IsoDate, IsoDateTime, MonthId, MutateOptions, SortOptions, UnixTimestamp, UnixTimestampMillis } from '../types.js';
|
|
2
|
+
import type { Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MonthId, 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.
|
|
@@ -148,7 +152,7 @@ export declare class LocalDate {
|
|
|
148
152
|
*/
|
|
149
153
|
toStringCompact(): string;
|
|
150
154
|
/**
|
|
151
|
-
*
|
|
155
|
+
* @deprecated Use toIsoMonth
|
|
152
156
|
*/
|
|
153
157
|
toMonthId(): MonthId;
|
|
154
158
|
/**
|
|
@@ -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.
|
|
@@ -429,10 +435,10 @@ export class LocalDate {
|
|
|
429
435
|
].join('');
|
|
430
436
|
}
|
|
431
437
|
/**
|
|
432
|
-
*
|
|
438
|
+
* @deprecated Use toIsoMonth
|
|
433
439
|
*/
|
|
434
440
|
toMonthId() {
|
|
435
|
-
return this.
|
|
441
|
+
return this.toISOMonth();
|
|
436
442
|
}
|
|
437
443
|
/**
|
|
438
444
|
* Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, MonthId, MutateOptions, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types.js';
|
|
1
|
+
import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MonthId, 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,6 +231,9 @@ export declare class LocalTime {
|
|
|
227
231
|
toStringCompact(seconds?: boolean): string;
|
|
228
232
|
toString(): IsoDateTime;
|
|
229
233
|
toJSON(): UnixTimestamp;
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated Use toIsoMonth
|
|
236
|
+
*/
|
|
230
237
|
toMonthId(): MonthId;
|
|
231
238
|
format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string;
|
|
232
239
|
}
|
|
@@ -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,8 +634,11 @@ export class LocalTime {
|
|
|
628
634
|
toJSON() {
|
|
629
635
|
return this.unix;
|
|
630
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* @deprecated Use toIsoMonth
|
|
639
|
+
*/
|
|
631
640
|
toMonthId() {
|
|
632
|
-
return this.
|
|
641
|
+
return this.toISOMonth();
|
|
633
642
|
}
|
|
634
643
|
format(fmt) {
|
|
635
644
|
if (fmt instanceof Intl.DateTimeFormat) {
|
package/dist/types.d.ts
CHANGED
|
@@ -191,10 +191,15 @@ 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
|
+
*/
|
|
199
|
+
export type IsoMonth = Branded<string, 'IsoMonth'>;
|
|
200
|
+
/**
|
|
201
|
+
* Identifies the Month.
|
|
202
|
+
* @deprecated Use IsoMonth
|
|
198
203
|
*/
|
|
199
204
|
export type MonthId = string;
|
|
200
205
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.48.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2",
|
|
7
7
|
"undici": "^7",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"types": "dist/index.d.ts",
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"engines": {
|
|
57
|
-
"node": ">=24.
|
|
57
|
+
"node": ">=24.11.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"provenance": true,
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
Inclusiveness,
|
|
5
5
|
IsoDate,
|
|
6
6
|
IsoDateTime,
|
|
7
|
+
IsoMonth,
|
|
7
8
|
MonthId,
|
|
8
9
|
MutateOptions,
|
|
9
10
|
SortOptions,
|
|
@@ -474,6 +475,13 @@ export class LocalDate {
|
|
|
474
475
|
].join('-') as IsoDate
|
|
475
476
|
}
|
|
476
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Returns e.g: `1984-06`
|
|
480
|
+
*/
|
|
481
|
+
toISOMonth(): IsoMonth {
|
|
482
|
+
return this.toISODate().slice(0, 7) as IsoMonth
|
|
483
|
+
}
|
|
484
|
+
|
|
477
485
|
/**
|
|
478
486
|
* Returns e.g: `1984-06-21T00:00:00`
|
|
479
487
|
* Hours, minutes and seconds are 0.
|
|
@@ -506,10 +514,10 @@ export class LocalDate {
|
|
|
506
514
|
}
|
|
507
515
|
|
|
508
516
|
/**
|
|
509
|
-
*
|
|
517
|
+
* @deprecated Use toIsoMonth
|
|
510
518
|
*/
|
|
511
519
|
toMonthId(): MonthId {
|
|
512
|
-
return this.
|
|
520
|
+
return this.toISOMonth()
|
|
513
521
|
}
|
|
514
522
|
|
|
515
523
|
/**
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
Inclusiveness,
|
|
5
5
|
IsoDate,
|
|
6
6
|
IsoDateTime,
|
|
7
|
+
IsoMonth,
|
|
7
8
|
MonthId,
|
|
8
9
|
MutateOptions,
|
|
9
10
|
NumberOfHours,
|
|
@@ -710,6 +711,13 @@ export class LocalTime {
|
|
|
710
711
|
// return this.$date.toISOString().slice(0, 10)
|
|
711
712
|
}
|
|
712
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Returns e.g: `1984-06`
|
|
716
|
+
*/
|
|
717
|
+
toISOMonth(): IsoMonth {
|
|
718
|
+
return this.toISODate().slice(0, 7) as IsoMonth
|
|
719
|
+
}
|
|
720
|
+
|
|
713
721
|
/**
|
|
714
722
|
* Returns e.g: `17:03:15` (or `17:03` with seconds=false)
|
|
715
723
|
*/
|
|
@@ -757,8 +765,11 @@ export class LocalTime {
|
|
|
757
765
|
return this.unix
|
|
758
766
|
}
|
|
759
767
|
|
|
768
|
+
/**
|
|
769
|
+
* @deprecated Use toIsoMonth
|
|
770
|
+
*/
|
|
760
771
|
toMonthId(): MonthId {
|
|
761
|
-
return this.
|
|
772
|
+
return this.toISOMonth()
|
|
762
773
|
}
|
|
763
774
|
|
|
764
775
|
format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string {
|
package/src/types.ts
CHANGED
|
@@ -247,10 +247,16 @@ 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
|
+
*/
|
|
255
|
+
export type IsoMonth = Branded<string, 'IsoMonth'>
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Identifies the Month.
|
|
259
|
+
* @deprecated Use IsoMonth
|
|
254
260
|
*/
|
|
255
261
|
export type MonthId = string
|
|
256
262
|
|