@naturalcycles/js-lib 14.273.0 → 14.274.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/localTime.d.ts +1 -0
- package/dist/datetime/localTime.js +3 -0
- package/dist/datetime/wallTime.d.ts +17 -2
- package/dist/datetime/wallTime.js +26 -0
- package/dist-esm/datetime/localTime.js +3 -0
- package/dist-esm/datetime/wallTime.js +26 -0
- package/package.json +5 -4
- package/src/datetime/localTime.ts +4 -0
- package/src/datetime/wallTime.ts +32 -2
|
@@ -607,6 +607,9 @@ class LocalTime {
|
|
|
607
607
|
// !! Not using toISOString(), as it returns time in UTC, not in local timezone (unexpected!)
|
|
608
608
|
// return this.$date.toISOString().slice(11, seconds ? 19 : 16)
|
|
609
609
|
}
|
|
610
|
+
toWallTime() {
|
|
611
|
+
return new wallTime_1.WallTime(this.toDateTimeObject());
|
|
612
|
+
}
|
|
610
613
|
/**
|
|
611
614
|
* Returns e.g: `19840621_1705`
|
|
612
615
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IsoDate } from '../types';
|
|
2
|
-
import {
|
|
1
|
+
import { IsoDate, IsoDateTime } from '../types';
|
|
2
|
+
import { LocalDate } from './localDate';
|
|
3
|
+
import { DateTimeObject, LocalTime } from './localTime';
|
|
3
4
|
/**
|
|
4
5
|
* Representation of a "time on the wall clock",
|
|
5
6
|
* which means "local time, regardless of timezone".
|
|
@@ -17,12 +18,26 @@ export declare class WallTime implements DateTimeObject {
|
|
|
17
18
|
minute: number;
|
|
18
19
|
second: number;
|
|
19
20
|
constructor(obj: DateTimeObject);
|
|
21
|
+
toLocalDate(): LocalDate;
|
|
22
|
+
/**
|
|
23
|
+
* Example:
|
|
24
|
+
* WallTime is 1984-06-21 17:56:21
|
|
25
|
+
* .toLocalTime() will return a LocalTime Date instance
|
|
26
|
+
* holding that time in the local timezone.
|
|
27
|
+
*/
|
|
28
|
+
toLocalTime(): LocalTime;
|
|
29
|
+
toJSON(): IsoDateTime;
|
|
30
|
+
toString(): IsoDateTime;
|
|
20
31
|
/**
|
|
21
32
|
* Returns e.g: `1984-06-21 17:56:21`
|
|
22
33
|
* or (if seconds=false):
|
|
23
34
|
* `1984-06-21 17:56`
|
|
24
35
|
*/
|
|
25
36
|
toPretty(seconds?: boolean): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
39
|
+
*/
|
|
40
|
+
toISODateTime(): IsoDateTime;
|
|
26
41
|
/**
|
|
27
42
|
* Returns e.g: `1984-06-21`, only the date part of DateTime
|
|
28
43
|
*/
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WallTime = void 0;
|
|
4
|
+
const localDate_1 = require("./localDate");
|
|
5
|
+
const localTime_1 = require("./localTime");
|
|
4
6
|
/**
|
|
5
7
|
* Representation of a "time on the wall clock",
|
|
6
8
|
* which means "local time, regardless of timezone".
|
|
@@ -14,6 +16,24 @@ class WallTime {
|
|
|
14
16
|
constructor(obj) {
|
|
15
17
|
Object.assign(this, obj);
|
|
16
18
|
}
|
|
19
|
+
toLocalDate() {
|
|
20
|
+
return new localDate_1.LocalDate(this.year, this.month, this.day);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Example:
|
|
24
|
+
* WallTime is 1984-06-21 17:56:21
|
|
25
|
+
* .toLocalTime() will return a LocalTime Date instance
|
|
26
|
+
* holding that time in the local timezone.
|
|
27
|
+
*/
|
|
28
|
+
toLocalTime() {
|
|
29
|
+
return localTime_1.localTime.fromDateTimeObject(this);
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return this.toISODateTime();
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this.toISODateTime();
|
|
36
|
+
}
|
|
17
37
|
/**
|
|
18
38
|
* Returns e.g: `1984-06-21 17:56:21`
|
|
19
39
|
* or (if seconds=false):
|
|
@@ -22,6 +42,12 @@ class WallTime {
|
|
|
22
42
|
toPretty(seconds = true) {
|
|
23
43
|
return this.toISODate() + ' ' + this.toISOTime(seconds);
|
|
24
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
47
|
+
*/
|
|
48
|
+
toISODateTime() {
|
|
49
|
+
return (this.toISODate() + 'T' + this.toISOTime());
|
|
50
|
+
}
|
|
25
51
|
/**
|
|
26
52
|
* Returns e.g: `1984-06-21`, only the date part of DateTime
|
|
27
53
|
*/
|
|
@@ -604,6 +604,9 @@ export class LocalTime {
|
|
|
604
604
|
// !! Not using toISOString(), as it returns time in UTC, not in local timezone (unexpected!)
|
|
605
605
|
// return this.$date.toISOString().slice(11, seconds ? 19 : 16)
|
|
606
606
|
}
|
|
607
|
+
toWallTime() {
|
|
608
|
+
return new WallTime(this.toDateTimeObject());
|
|
609
|
+
}
|
|
607
610
|
/**
|
|
608
611
|
* Returns e.g: `19840621_1705`
|
|
609
612
|
*/
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LocalDate } from './localDate';
|
|
2
|
+
import { localTime } from './localTime';
|
|
1
3
|
/**
|
|
2
4
|
* Representation of a "time on the wall clock",
|
|
3
5
|
* which means "local time, regardless of timezone".
|
|
@@ -11,6 +13,24 @@ export class WallTime {
|
|
|
11
13
|
constructor(obj) {
|
|
12
14
|
Object.assign(this, obj);
|
|
13
15
|
}
|
|
16
|
+
toLocalDate() {
|
|
17
|
+
return new LocalDate(this.year, this.month, this.day);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Example:
|
|
21
|
+
* WallTime is 1984-06-21 17:56:21
|
|
22
|
+
* .toLocalTime() will return a LocalTime Date instance
|
|
23
|
+
* holding that time in the local timezone.
|
|
24
|
+
*/
|
|
25
|
+
toLocalTime() {
|
|
26
|
+
return localTime.fromDateTimeObject(this);
|
|
27
|
+
}
|
|
28
|
+
toJSON() {
|
|
29
|
+
return this.toISODateTime();
|
|
30
|
+
}
|
|
31
|
+
toString() {
|
|
32
|
+
return this.toISODateTime();
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* Returns e.g: `1984-06-21 17:56:21`
|
|
16
36
|
* or (if seconds=false):
|
|
@@ -19,6 +39,12 @@ export class WallTime {
|
|
|
19
39
|
toPretty(seconds = true) {
|
|
20
40
|
return this.toISODate() + ' ' + this.toISOTime(seconds);
|
|
21
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
44
|
+
*/
|
|
45
|
+
toISODateTime() {
|
|
46
|
+
return (this.toISODate() + 'T' + this.toISOTime());
|
|
47
|
+
}
|
|
22
48
|
/**
|
|
23
49
|
* Returns e.g: `1984-06-21`, only the date part of DateTime
|
|
24
50
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.274.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"build": "dev-lib build-esm-cjs",
|
|
@@ -21,16 +21,17 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@naturalcycles/bench-lib": "^3",
|
|
24
|
-
"@naturalcycles/dev-lib": "^
|
|
24
|
+
"@naturalcycles/dev-lib": "^17",
|
|
25
25
|
"@naturalcycles/nodejs-lib": "^13",
|
|
26
26
|
"@naturalcycles/time-lib": "^3",
|
|
27
27
|
"@types/crypto-js": "^4",
|
|
28
28
|
"@types/node": "^22",
|
|
29
29
|
"@types/semver": "^7",
|
|
30
|
+
"@vitest/coverage-v8": "^3",
|
|
30
31
|
"crypto-js": "^4",
|
|
31
|
-
"
|
|
32
|
-
"prettier": "^3",
|
|
32
|
+
"tsx": "^4.19.3",
|
|
33
33
|
"vitepress": "^1",
|
|
34
|
+
"vitest": "^3",
|
|
34
35
|
"vue": "^3"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
package/src/datetime/wallTime.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IsoDate } from '../types'
|
|
2
|
-
import {
|
|
1
|
+
import { IsoDate, IsoDateTime } from '../types'
|
|
2
|
+
import { LocalDate } from './localDate'
|
|
3
|
+
import { DateTimeObject, LocalTime, localTime } from './localTime'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Representation of a "time on the wall clock",
|
|
@@ -22,6 +23,28 @@ export class WallTime implements DateTimeObject {
|
|
|
22
23
|
Object.assign(this, obj)
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
toLocalDate(): LocalDate {
|
|
27
|
+
return new LocalDate(this.year, this.month, this.day)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Example:
|
|
32
|
+
* WallTime is 1984-06-21 17:56:21
|
|
33
|
+
* .toLocalTime() will return a LocalTime Date instance
|
|
34
|
+
* holding that time in the local timezone.
|
|
35
|
+
*/
|
|
36
|
+
toLocalTime(): LocalTime {
|
|
37
|
+
return localTime.fromDateTimeObject(this)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
toJSON(): IsoDateTime {
|
|
41
|
+
return this.toISODateTime()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
toString(): IsoDateTime {
|
|
45
|
+
return this.toISODateTime()
|
|
46
|
+
}
|
|
47
|
+
|
|
25
48
|
/**
|
|
26
49
|
* Returns e.g: `1984-06-21 17:56:21`
|
|
27
50
|
* or (if seconds=false):
|
|
@@ -31,6 +54,13 @@ export class WallTime implements DateTimeObject {
|
|
|
31
54
|
return this.toISODate() + ' ' + this.toISOTime(seconds)
|
|
32
55
|
}
|
|
33
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
59
|
+
*/
|
|
60
|
+
toISODateTime(): IsoDateTime {
|
|
61
|
+
return (this.toISODate() + 'T' + this.toISOTime()) as IsoDateTime
|
|
62
|
+
}
|
|
63
|
+
|
|
34
64
|
/**
|
|
35
65
|
* Returns e.g: `1984-06-21`, only the date part of DateTime
|
|
36
66
|
*/
|