@naturalcycles/js-lib 14.181.1 → 14.183.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 +11 -3
- package/dist/datetime/localDate.js +18 -4
- package/dist/datetime/localTime.d.ts +10 -2
- package/dist/datetime/localTime.js +17 -3
- package/dist/env/buildInfo.js +1 -1
- package/dist-esm/datetime/localDate.js +15 -3
- package/dist-esm/datetime/localTime.js +14 -2
- package/dist-esm/env/buildInfo.js +2 -2
- package/package.json +1 -1
- package/src/datetime/localDate.ts +18 -4
- package/src/datetime/localTime.ts +17 -3
- package/src/env/buildInfo.ts +2 -2
|
@@ -15,7 +15,7 @@ export declare class LocalDate {
|
|
|
15
15
|
private constructor();
|
|
16
16
|
static create(year: number, month: number, day: number): LocalDate;
|
|
17
17
|
/**
|
|
18
|
-
* Parses input
|
|
18
|
+
* Parses input into LocalDate.
|
|
19
19
|
* Input can already be a LocalDate - it is returned as-is in that case.
|
|
20
20
|
*/
|
|
21
21
|
static of(d: LocalDateInput): LocalDate;
|
|
@@ -94,12 +94,20 @@ export declare class LocalDate {
|
|
|
94
94
|
format(fmt: Intl.DateTimeFormat | LocalDateFormatter): string;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* Convenience wrapper around `LocalDate.of`
|
|
98
98
|
*/
|
|
99
|
-
export declare function localDate(d
|
|
99
|
+
export declare function localDate(d: LocalDateInput): LocalDate;
|
|
100
|
+
/**
|
|
101
|
+
* Convenience wrapper around `LocalDate.today`
|
|
102
|
+
*/
|
|
103
|
+
export declare function localDateToday(): LocalDate;
|
|
100
104
|
/**
|
|
101
105
|
* Creates a LocalDate from the input, unless it's falsy - then returns undefined.
|
|
102
106
|
*
|
|
103
107
|
* `localDate` function will instead return LocalDate of today for falsy input.
|
|
104
108
|
*/
|
|
105
109
|
export declare function localDateOrUndefined(d?: LocalDateInput | null): LocalDate | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Creates a LocalDate from the input, unless it's falsy - then returns LocalDate.today.
|
|
112
|
+
*/
|
|
113
|
+
export declare function localDateOrToday(d?: LocalDateInput | null): LocalDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localDateOrUndefined = exports.localDate = exports.LocalDate = void 0;
|
|
3
|
+
exports.localDateOrToday = exports.localDateOrUndefined = exports.localDateToday = exports.localDate = exports.LocalDate = void 0;
|
|
4
4
|
const assert_1 = require("../error/assert");
|
|
5
5
|
const localTime_1 = require("./localTime");
|
|
6
6
|
const MDAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
@@ -18,7 +18,7 @@ class LocalDate {
|
|
|
18
18
|
return new LocalDate(year, month, day);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Parses input
|
|
21
|
+
* Parses input into LocalDate.
|
|
22
22
|
* Input can already be a LocalDate - it is returned as-is in that case.
|
|
23
23
|
*/
|
|
24
24
|
static of(d) {
|
|
@@ -412,12 +412,19 @@ class LocalDate {
|
|
|
412
412
|
}
|
|
413
413
|
exports.LocalDate = LocalDate;
|
|
414
414
|
/**
|
|
415
|
-
*
|
|
415
|
+
* Convenience wrapper around `LocalDate.of`
|
|
416
416
|
*/
|
|
417
417
|
function localDate(d) {
|
|
418
|
-
return
|
|
418
|
+
return LocalDate.of(d);
|
|
419
419
|
}
|
|
420
420
|
exports.localDate = localDate;
|
|
421
|
+
/**
|
|
422
|
+
* Convenience wrapper around `LocalDate.today`
|
|
423
|
+
*/
|
|
424
|
+
function localDateToday() {
|
|
425
|
+
return LocalDate.today();
|
|
426
|
+
}
|
|
427
|
+
exports.localDateToday = localDateToday;
|
|
421
428
|
/**
|
|
422
429
|
* Creates a LocalDate from the input, unless it's falsy - then returns undefined.
|
|
423
430
|
*
|
|
@@ -427,3 +434,10 @@ function localDateOrUndefined(d) {
|
|
|
427
434
|
return d ? LocalDate.of(d) : undefined;
|
|
428
435
|
}
|
|
429
436
|
exports.localDateOrUndefined = localDateOrUndefined;
|
|
437
|
+
/**
|
|
438
|
+
* Creates a LocalDate from the input, unless it's falsy - then returns LocalDate.today.
|
|
439
|
+
*/
|
|
440
|
+
function localDateOrToday(d) {
|
|
441
|
+
return d ? LocalDate.of(d) : LocalDate.today();
|
|
442
|
+
}
|
|
443
|
+
exports.localDateOrToday = localDateOrToday;
|
|
@@ -123,12 +123,20 @@ export declare class LocalTime {
|
|
|
123
123
|
format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* Shortcut wrapper around `
|
|
126
|
+
* Shortcut wrapper around `LocalTime.of`
|
|
127
127
|
*/
|
|
128
|
-
export declare function localTime(d
|
|
128
|
+
export declare function localTime(d: LocalTimeInput): LocalTime;
|
|
129
|
+
/**
|
|
130
|
+
* Shortcut wrapper around `LocalTime.now`
|
|
131
|
+
*/
|
|
132
|
+
export declare function localTimeNow(): LocalTime;
|
|
129
133
|
/**
|
|
130
134
|
* Creates a LocalTime from the input, unless it's falsy - then returns undefined.
|
|
131
135
|
*
|
|
132
136
|
* `localTime` function will instead return LocalTime of `now` for falsy input.
|
|
133
137
|
*/
|
|
134
138
|
export declare function localTimeOrUndefined(d?: LocalTimeInput | null): LocalTime | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
|
|
141
|
+
*/
|
|
142
|
+
export declare function localTimeOrNow(d?: LocalTimeInput | null): LocalTime;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localTimeOrUndefined = exports.localTime = exports.LocalTime = exports.ISODayOfWeek = void 0;
|
|
3
|
+
exports.localTimeOrNow = exports.localTimeOrUndefined = exports.localTimeNow = exports.localTime = exports.LocalTime = exports.ISODayOfWeek = void 0;
|
|
4
4
|
const assert_1 = require("../error/assert");
|
|
5
5
|
const time_util_1 = require("../time/time.util");
|
|
6
6
|
const localDate_1 = require("./localDate");
|
|
@@ -489,12 +489,19 @@ class LocalTime {
|
|
|
489
489
|
}
|
|
490
490
|
exports.LocalTime = LocalTime;
|
|
491
491
|
/**
|
|
492
|
-
* Shortcut wrapper around `
|
|
492
|
+
* Shortcut wrapper around `LocalTime.of`
|
|
493
493
|
*/
|
|
494
494
|
function localTime(d) {
|
|
495
|
-
return
|
|
495
|
+
return LocalTime.of(d);
|
|
496
496
|
}
|
|
497
497
|
exports.localTime = localTime;
|
|
498
|
+
/**
|
|
499
|
+
* Shortcut wrapper around `LocalTime.now`
|
|
500
|
+
*/
|
|
501
|
+
function localTimeNow() {
|
|
502
|
+
return LocalTime.now();
|
|
503
|
+
}
|
|
504
|
+
exports.localTimeNow = localTimeNow;
|
|
498
505
|
/**
|
|
499
506
|
* Creates a LocalTime from the input, unless it's falsy - then returns undefined.
|
|
500
507
|
*
|
|
@@ -504,6 +511,13 @@ function localTimeOrUndefined(d) {
|
|
|
504
511
|
return d ? LocalTime.of(d) : undefined;
|
|
505
512
|
}
|
|
506
513
|
exports.localTimeOrUndefined = localTimeOrUndefined;
|
|
514
|
+
/**
|
|
515
|
+
* Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
|
|
516
|
+
*/
|
|
517
|
+
function localTimeOrNow(d) {
|
|
518
|
+
return d ? LocalTime.of(d) : LocalTime.now();
|
|
519
|
+
}
|
|
520
|
+
exports.localTimeOrNow = localTimeOrNow;
|
|
507
521
|
// based on: https://github.com/date-fns/date-fns/blob/master/src/getISOWeek/index.ts
|
|
508
522
|
function getWeek(date) {
|
|
509
523
|
const diff = startOfWeek(date).getTime() - startOfWeekYear(date).getTime();
|
package/dist/env/buildInfo.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateBuildInfoDev = void 0;
|
|
4
4
|
const localTime_1 = require("../datetime/localTime");
|
|
5
5
|
function generateBuildInfoDev() {
|
|
6
|
-
const now = (0, localTime_1.
|
|
6
|
+
const now = (0, localTime_1.localTimeNow)();
|
|
7
7
|
const ts = now.unix();
|
|
8
8
|
const rev = 'devRev';
|
|
9
9
|
const branchName = 'devBranch';
|
|
@@ -15,7 +15,7 @@ export class LocalDate {
|
|
|
15
15
|
return new LocalDate(year, month, day);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Parses input
|
|
18
|
+
* Parses input into LocalDate.
|
|
19
19
|
* Input can already be a LocalDate - it is returned as-is in that case.
|
|
20
20
|
*/
|
|
21
21
|
static of(d) {
|
|
@@ -408,10 +408,16 @@ export class LocalDate {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
411
|
-
*
|
|
411
|
+
* Convenience wrapper around `LocalDate.of`
|
|
412
412
|
*/
|
|
413
413
|
export function localDate(d) {
|
|
414
|
-
return
|
|
414
|
+
return LocalDate.of(d);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Convenience wrapper around `LocalDate.today`
|
|
418
|
+
*/
|
|
419
|
+
export function localDateToday() {
|
|
420
|
+
return LocalDate.today();
|
|
415
421
|
}
|
|
416
422
|
/**
|
|
417
423
|
* Creates a LocalDate from the input, unless it's falsy - then returns undefined.
|
|
@@ -421,3 +427,9 @@ export function localDate(d) {
|
|
|
421
427
|
export function localDateOrUndefined(d) {
|
|
422
428
|
return d ? LocalDate.of(d) : undefined;
|
|
423
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Creates a LocalDate from the input, unless it's falsy - then returns LocalDate.today.
|
|
432
|
+
*/
|
|
433
|
+
export function localDateOrToday(d) {
|
|
434
|
+
return d ? LocalDate.of(d) : LocalDate.today();
|
|
435
|
+
}
|
|
@@ -486,10 +486,16 @@ export class LocalTime {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
/**
|
|
489
|
-
* Shortcut wrapper around `
|
|
489
|
+
* Shortcut wrapper around `LocalTime.of`
|
|
490
490
|
*/
|
|
491
491
|
export function localTime(d) {
|
|
492
|
-
return
|
|
492
|
+
return LocalTime.of(d);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Shortcut wrapper around `LocalTime.now`
|
|
496
|
+
*/
|
|
497
|
+
export function localTimeNow() {
|
|
498
|
+
return LocalTime.now();
|
|
493
499
|
}
|
|
494
500
|
/**
|
|
495
501
|
* Creates a LocalTime from the input, unless it's falsy - then returns undefined.
|
|
@@ -499,6 +505,12 @@ export function localTime(d) {
|
|
|
499
505
|
export function localTimeOrUndefined(d) {
|
|
500
506
|
return d ? LocalTime.of(d) : undefined;
|
|
501
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
|
|
510
|
+
*/
|
|
511
|
+
export function localTimeOrNow(d) {
|
|
512
|
+
return d ? LocalTime.of(d) : LocalTime.now();
|
|
513
|
+
}
|
|
502
514
|
// based on: https://github.com/date-fns/date-fns/blob/master/src/getISOWeek/index.ts
|
|
503
515
|
function getWeek(date) {
|
|
504
516
|
const diff = startOfWeek(date).getTime() - startOfWeekYear(date).getTime();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localTimeNow } from '../datetime/localTime';
|
|
2
2
|
export function generateBuildInfoDev() {
|
|
3
|
-
const now =
|
|
3
|
+
const now = localTimeNow();
|
|
4
4
|
const ts = now.unix();
|
|
5
5
|
const rev = 'devRev';
|
|
6
6
|
const branchName = 'devBranch';
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ export class LocalDate {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Parses input
|
|
35
|
+
* Parses input into LocalDate.
|
|
36
36
|
* Input can already be a LocalDate - it is returned as-is in that case.
|
|
37
37
|
*/
|
|
38
38
|
static of(d: LocalDateInput): LocalDate {
|
|
@@ -505,10 +505,17 @@ export class LocalDate {
|
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
/**
|
|
508
|
-
*
|
|
508
|
+
* Convenience wrapper around `LocalDate.of`
|
|
509
509
|
*/
|
|
510
|
-
export function localDate(d
|
|
511
|
-
return
|
|
510
|
+
export function localDate(d: LocalDateInput): LocalDate {
|
|
511
|
+
return LocalDate.of(d)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Convenience wrapper around `LocalDate.today`
|
|
516
|
+
*/
|
|
517
|
+
export function localDateToday(): LocalDate {
|
|
518
|
+
return LocalDate.today()
|
|
512
519
|
}
|
|
513
520
|
|
|
514
521
|
/**
|
|
@@ -519,3 +526,10 @@ export function localDate(d?: LocalDateInput | null): LocalDate {
|
|
|
519
526
|
export function localDateOrUndefined(d?: LocalDateInput | null): LocalDate | undefined {
|
|
520
527
|
return d ? LocalDate.of(d) : undefined
|
|
521
528
|
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Creates a LocalDate from the input, unless it's falsy - then returns LocalDate.today.
|
|
532
|
+
*/
|
|
533
|
+
export function localDateOrToday(d?: LocalDateInput | null): LocalDate {
|
|
534
|
+
return d ? LocalDate.of(d) : LocalDate.today()
|
|
535
|
+
}
|
|
@@ -597,10 +597,17 @@ export class LocalTime {
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
/**
|
|
600
|
-
* Shortcut wrapper around `
|
|
600
|
+
* Shortcut wrapper around `LocalTime.of`
|
|
601
601
|
*/
|
|
602
|
-
export function localTime(d
|
|
603
|
-
return
|
|
602
|
+
export function localTime(d: LocalTimeInput): LocalTime {
|
|
603
|
+
return LocalTime.of(d)
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Shortcut wrapper around `LocalTime.now`
|
|
608
|
+
*/
|
|
609
|
+
export function localTimeNow(): LocalTime {
|
|
610
|
+
return LocalTime.now()
|
|
604
611
|
}
|
|
605
612
|
|
|
606
613
|
/**
|
|
@@ -612,6 +619,13 @@ export function localTimeOrUndefined(d?: LocalTimeInput | null): LocalTime | und
|
|
|
612
619
|
return d ? LocalTime.of(d) : undefined
|
|
613
620
|
}
|
|
614
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
|
|
624
|
+
*/
|
|
625
|
+
export function localTimeOrNow(d?: LocalTimeInput | null): LocalTime {
|
|
626
|
+
return d ? LocalTime.of(d) : LocalTime.now()
|
|
627
|
+
}
|
|
628
|
+
|
|
615
629
|
// based on: https://github.com/date-fns/date-fns/blob/master/src/getISOWeek/index.ts
|
|
616
630
|
function getWeek(date: Date): number {
|
|
617
631
|
const diff = startOfWeek(date).getTime() - startOfWeekYear(date).getTime()
|
package/src/env/buildInfo.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localTimeNow } from '../datetime/localTime'
|
|
2
2
|
import type { UnixTimestampNumber } from '../types'
|
|
3
3
|
|
|
4
4
|
export interface BuildInfo {
|
|
@@ -43,7 +43,7 @@ export interface BuildInfo {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export function generateBuildInfoDev(): BuildInfo {
|
|
46
|
-
const now =
|
|
46
|
+
const now = localTimeNow()
|
|
47
47
|
const ts = now.unix()
|
|
48
48
|
const rev = 'devRev'
|
|
49
49
|
const branchName = 'devBranch'
|