@naturalcycles/js-lib 14.91.1 → 14.91.2
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 +4 -1
- package/dist/datetime/localDate.js +10 -0
- package/dist/datetime/localTime.d.ts +1 -0
- package/dist/datetime/localTime.js +3 -0
- package/dist-esm/datetime/localDate.js +10 -0
- package/dist-esm/datetime/localTime.js +3 -0
- package/package.json +1 -1
- package/src/datetime/localDate.ts +14 -1
- package/src/datetime/localTime.ts +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sequence } from '../seq/seq';
|
|
2
|
-
import { IsoDate } from '../types';
|
|
2
|
+
import { IsoDate, UnixTimestamp } from '../types';
|
|
3
3
|
import { LocalTime } from './localTime';
|
|
4
4
|
export declare type LocalDateUnit = 'year' | 'month' | 'day';
|
|
5
5
|
export declare type LocalDateConfig = LocalDate | string;
|
|
@@ -72,8 +72,11 @@ export declare class LocalDate {
|
|
|
72
72
|
*/
|
|
73
73
|
toDate(): Date;
|
|
74
74
|
toLocalTime(): LocalTime;
|
|
75
|
+
toISODate(): IsoDate;
|
|
75
76
|
toString(): IsoDate;
|
|
76
77
|
toStringCompact(): string;
|
|
78
|
+
unix(): UnixTimestamp;
|
|
79
|
+
unixMillis(): number;
|
|
77
80
|
toJSON(): IsoDate;
|
|
78
81
|
}
|
|
79
82
|
/**
|
|
@@ -286,6 +286,9 @@ class LocalDate {
|
|
|
286
286
|
toLocalTime() {
|
|
287
287
|
return localTime_1.LocalTime.of(this.toDate());
|
|
288
288
|
}
|
|
289
|
+
toISODate() {
|
|
290
|
+
return this.toString();
|
|
291
|
+
}
|
|
289
292
|
toString() {
|
|
290
293
|
return [
|
|
291
294
|
String(this.year).padStart(4, '0'),
|
|
@@ -300,6 +303,13 @@ class LocalDate {
|
|
|
300
303
|
String(this.day).padStart(2, '0'),
|
|
301
304
|
].join('');
|
|
302
305
|
}
|
|
306
|
+
// May be not optimal, as LocalTime better suits it
|
|
307
|
+
unix() {
|
|
308
|
+
return Math.floor(this.toDate().valueOf() / 1000);
|
|
309
|
+
}
|
|
310
|
+
unixMillis() {
|
|
311
|
+
return this.toDate().valueOf();
|
|
312
|
+
}
|
|
303
313
|
toJSON() {
|
|
304
314
|
return this.toString();
|
|
305
315
|
}
|
|
@@ -283,6 +283,9 @@ export class LocalDate {
|
|
|
283
283
|
toLocalTime() {
|
|
284
284
|
return LocalTime.of(this.toDate());
|
|
285
285
|
}
|
|
286
|
+
toISODate() {
|
|
287
|
+
return this.toString();
|
|
288
|
+
}
|
|
286
289
|
toString() {
|
|
287
290
|
return [
|
|
288
291
|
String(this.year).padStart(4, '0'),
|
|
@@ -297,6 +300,13 @@ export class LocalDate {
|
|
|
297
300
|
String(this.day).padStart(2, '0'),
|
|
298
301
|
].join('');
|
|
299
302
|
}
|
|
303
|
+
// May be not optimal, as LocalTime better suits it
|
|
304
|
+
unix() {
|
|
305
|
+
return Math.floor(this.toDate().valueOf() / 1000);
|
|
306
|
+
}
|
|
307
|
+
unixMillis() {
|
|
308
|
+
return this.toDate().valueOf();
|
|
309
|
+
}
|
|
300
310
|
toJSON() {
|
|
301
311
|
return this.toString();
|
|
302
312
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
2
|
import { Sequence } from '../seq/seq'
|
|
3
|
-
import { END, IsoDate } from '../types'
|
|
3
|
+
import { END, IsoDate, UnixTimestamp } from '../types'
|
|
4
4
|
import { LocalTime } from './localTime'
|
|
5
5
|
|
|
6
6
|
export type LocalDateUnit = 'year' | 'month' | 'day'
|
|
@@ -361,6 +361,10 @@ export class LocalDate {
|
|
|
361
361
|
return LocalTime.of(this.toDate())
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
toISODate(): IsoDate {
|
|
365
|
+
return this.toString()
|
|
366
|
+
}
|
|
367
|
+
|
|
364
368
|
toString(): IsoDate {
|
|
365
369
|
return [
|
|
366
370
|
String(this.year).padStart(4, '0'),
|
|
@@ -377,6 +381,15 @@ export class LocalDate {
|
|
|
377
381
|
].join('')
|
|
378
382
|
}
|
|
379
383
|
|
|
384
|
+
// May be not optimal, as LocalTime better suits it
|
|
385
|
+
unix(): UnixTimestamp {
|
|
386
|
+
return Math.floor(this.toDate().valueOf() / 1000)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
unixMillis(): number {
|
|
390
|
+
return this.toDate().valueOf()
|
|
391
|
+
}
|
|
392
|
+
|
|
380
393
|
toJSON(): IsoDate {
|
|
381
394
|
return this.toString()
|
|
382
395
|
}
|