@bgord/tools 1.2.6 → 1.2.7
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/timestamp.vo.d.ts +2 -0
- package/dist/timestamp.vo.js +6 -0
- package/package.json +2 -2
- package/src/timestamp.vo.ts +8 -0
package/dist/timestamp.vo.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare class Timestamp {
|
|
|
5
5
|
constructor(value: TimestampValueType);
|
|
6
6
|
static fromValue(value: TimestampValueType): Timestamp;
|
|
7
7
|
static fromNumber(value: number): Timestamp;
|
|
8
|
+
static fromDate(value: Date): Timestamp;
|
|
9
|
+
static fromDateLike(value: string): Timestamp;
|
|
8
10
|
add(duration: Duration): Timestamp;
|
|
9
11
|
subtract(duration: Duration): Timestamp;
|
|
10
12
|
difference(another: Timestamp): Duration;
|
package/dist/timestamp.vo.js
CHANGED
|
@@ -11,6 +11,12 @@ export class Timestamp {
|
|
|
11
11
|
static fromNumber(value) {
|
|
12
12
|
return new Timestamp(TimestampValue.parse(value));
|
|
13
13
|
}
|
|
14
|
+
static fromDate(value) {
|
|
15
|
+
return Timestamp.fromNumber(value.getTime());
|
|
16
|
+
}
|
|
17
|
+
static fromDateLike(value) {
|
|
18
|
+
return Timestamp.fromNumber(new Date(value).getTime());
|
|
19
|
+
}
|
|
14
20
|
add(duration) {
|
|
15
21
|
return Timestamp.fromNumber(this.value + duration.ms);
|
|
16
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/tools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@types/bun": "1.3.5",
|
|
28
28
|
"@types/mime-types": "3.0.1",
|
|
29
29
|
"cspell": "9.4.0",
|
|
30
|
-
"knip": "5.
|
|
30
|
+
"knip": "5.78.0",
|
|
31
31
|
"lefthook": "2.0.13",
|
|
32
32
|
"lockfile-lint": "4.14.1",
|
|
33
33
|
"only-allow": "1.2.2",
|
package/src/timestamp.vo.ts
CHANGED
|
@@ -12,6 +12,14 @@ export class Timestamp {
|
|
|
12
12
|
return new Timestamp(TimestampValue.parse(value));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
static fromDate(value: Date): Timestamp {
|
|
16
|
+
return Timestamp.fromNumber(value.getTime());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static fromDateLike(value: string): Timestamp {
|
|
20
|
+
return Timestamp.fromNumber(new Date(value).getTime());
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
add(duration: Duration): Timestamp {
|
|
16
24
|
return Timestamp.fromNumber(this.value + duration.ms);
|
|
17
25
|
}
|