@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.
@@ -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
  }
@@ -72,6 +72,7 @@ export declare class LocalTime {
72
72
  getDate(): Date;
73
73
  clone(): LocalTime;
74
74
  unix(): UnixTimestamp;
75
+ unixMillis(): number;
75
76
  valueOf(): UnixTimestamp;
76
77
  toLocalDate(): LocalDate;
77
78
  toPretty(seconds?: boolean): IsoDateTime;
@@ -295,6 +295,9 @@ class LocalTime {
295
295
  unix() {
296
296
  return Math.floor(this.$date.valueOf() / 1000);
297
297
  }
298
+ unixMillis() {
299
+ return this.$date.valueOf();
300
+ }
298
301
  valueOf() {
299
302
  return Math.floor(this.$date.valueOf() / 1000);
300
303
  }
@@ -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
  }
@@ -292,6 +292,9 @@ export class LocalTime {
292
292
  unix() {
293
293
  return Math.floor(this.$date.valueOf() / 1000);
294
294
  }
295
+ unixMillis() {
296
+ return this.$date.valueOf();
297
+ }
295
298
  valueOf() {
296
299
  return Math.floor(this.$date.valueOf() / 1000);
297
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.91.1",
3
+ "version": "14.91.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -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
  }
@@ -352,6 +352,10 @@ export class LocalTime {
352
352
  return Math.floor(this.$date.valueOf() / 1000)
353
353
  }
354
354
 
355
+ unixMillis(): number {
356
+ return this.$date.valueOf()
357
+ }
358
+
355
359
  valueOf(): UnixTimestamp {
356
360
  return Math.floor(this.$date.valueOf() / 1000)
357
361
  }