@naturalcycles/js-lib 14.231.0 → 14.232.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.
|
@@ -50,7 +50,16 @@ export declare class LocalTime {
|
|
|
50
50
|
year: number;
|
|
51
51
|
month: number;
|
|
52
52
|
} & Partial<LocalTimeComponents>): LocalTime;
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in UTC timezone.
|
|
55
|
+
* Opposite of `.local()` method.
|
|
56
|
+
*/
|
|
57
|
+
utc(): LocalTime;
|
|
58
|
+
/**
|
|
59
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in local timezone.
|
|
60
|
+
* Opposite of `.utc()` method.
|
|
61
|
+
*/
|
|
62
|
+
local(): LocalTime;
|
|
54
63
|
get(unit: LocalTimeUnit): number;
|
|
55
64
|
set(unit: LocalTimeUnit, v: number, mutate?: boolean): LocalTime;
|
|
56
65
|
year(): number;
|
|
@@ -76,9 +76,6 @@ class LocalTime {
|
|
|
76
76
|
// throw new TypeError(`Cannot parse "${d}" into LocalTime`)
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
-
// if (utc) {
|
|
80
|
-
// date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
|
|
81
|
-
// }
|
|
82
79
|
return new LocalTime(date);
|
|
83
80
|
}
|
|
84
81
|
static parseToDate(d) {
|
|
@@ -112,8 +109,19 @@ class LocalTime {
|
|
|
112
109
|
static fromComponents(c) {
|
|
113
110
|
return new LocalTime(new Date(c.year, c.month - 1, c.day || 1, c.hour || 0, c.minute || 0, c.second || 0));
|
|
114
111
|
}
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in UTC timezone.
|
|
114
|
+
* Opposite of `.local()` method.
|
|
115
|
+
*/
|
|
116
|
+
utc() {
|
|
117
|
+
return new LocalTime(new Date(this.$date.toISOString()));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in local timezone.
|
|
121
|
+
* Opposite of `.utc()` method.
|
|
122
|
+
*/
|
|
123
|
+
local() {
|
|
124
|
+
return new LocalTime(new Date(this.$date.getTime()));
|
|
117
125
|
}
|
|
118
126
|
get(unit) {
|
|
119
127
|
if (unit === 'year') {
|
|
@@ -73,9 +73,6 @@ export class LocalTime {
|
|
|
73
73
|
// throw new TypeError(`Cannot parse "${d}" into LocalTime`)
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
|
-
// if (utc) {
|
|
77
|
-
// date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
|
|
78
|
-
// }
|
|
79
76
|
return new LocalTime(date);
|
|
80
77
|
}
|
|
81
78
|
static parseToDate(d) {
|
|
@@ -109,8 +106,19 @@ export class LocalTime {
|
|
|
109
106
|
static fromComponents(c) {
|
|
110
107
|
return new LocalTime(new Date(c.year, c.month - 1, c.day || 1, c.hour || 0, c.minute || 0, c.second || 0));
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in UTC timezone.
|
|
111
|
+
* Opposite of `.local()` method.
|
|
112
|
+
*/
|
|
113
|
+
utc() {
|
|
114
|
+
return new LocalTime(new Date(this.$date.toISOString()));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in local timezone.
|
|
118
|
+
* Opposite of `.utc()` method.
|
|
119
|
+
*/
|
|
120
|
+
local() {
|
|
121
|
+
return new LocalTime(new Date(this.$date.getTime()));
|
|
114
122
|
}
|
|
115
123
|
get(unit) {
|
|
116
124
|
if (unit === 'year') {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.232.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
7
|
-
"test-tz1": "TZ=Europe/Stockholm test local",
|
|
8
|
-
"test-tz2": "TZ=JST-9 test local",
|
|
7
|
+
"test-tz1": "TZ=Europe/Stockholm yarn test local",
|
|
8
|
+
"test-tz2": "TZ=JST-9 yarn test local",
|
|
9
9
|
"docs-dev": "vitepress dev docs --open",
|
|
10
10
|
"docs-build": "vitepress build docs",
|
|
11
11
|
"docs-preview": "vitepress preview docs"
|
|
@@ -107,10 +107,6 @@ export class LocalTime {
|
|
|
107
107
|
return null
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
// if (utc) {
|
|
111
|
-
// date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
|
|
112
|
-
// }
|
|
113
|
-
|
|
114
110
|
return new LocalTime(date)
|
|
115
111
|
}
|
|
116
112
|
|
|
@@ -156,8 +152,20 @@ export class LocalTime {
|
|
|
156
152
|
)
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in UTC timezone.
|
|
157
|
+
* Opposite of `.local()` method.
|
|
158
|
+
*/
|
|
159
|
+
utc(): LocalTime {
|
|
160
|
+
return new LocalTime(new Date(this.$date.toISOString()))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns LocalTime that is based on the same unixtimestamp, but in local timezone.
|
|
165
|
+
* Opposite of `.utc()` method.
|
|
166
|
+
*/
|
|
167
|
+
local(): LocalTime {
|
|
168
|
+
return new LocalTime(new Date(this.$date.getTime()))
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
get(unit: LocalTimeUnit): number {
|