test-entity-library-asm 3.3.5 → 3.3.6
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
|
-
import { ValueTransformer } from
|
|
1
|
+
import { ValueTransformer } from "typeorm";
|
|
2
2
|
export declare class DateTransformer implements ValueTransformer {
|
|
3
3
|
to(value: Date | string): string;
|
|
4
|
-
from(value: string): string;
|
|
4
|
+
from(value: string): Date | null | string;
|
|
5
5
|
}
|
|
@@ -7,14 +7,13 @@ var DateTransformer = /** @class */ (function () {
|
|
|
7
7
|
function DateTransformer() {
|
|
8
8
|
}
|
|
9
9
|
DateTransformer.prototype.to = function (value) {
|
|
10
|
-
var result = moment(value).format(
|
|
10
|
+
var result = moment(value).format("YYYY-MM-DD HH:mm:ss");
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
DateTransformer.prototype.from = function (value) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.format('YYYY-MM-DD HH:mm:ss');
|
|
14
|
+
if (value === null)
|
|
15
|
+
return null;
|
|
16
|
+
var result = moment.utc(value).tz((0, __1.getTimeZone)()).toDate();
|
|
18
17
|
return result;
|
|
19
18
|
};
|
|
20
19
|
return DateTransformer;
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { ValueTransformer } from
|
|
2
|
-
import * as moment from
|
|
3
|
-
import { getTimeZone } from
|
|
1
|
+
import { ValueTransformer } from "typeorm";
|
|
2
|
+
import * as moment from "moment-timezone";
|
|
3
|
+
import { getTimeZone } from "..";
|
|
4
4
|
|
|
5
5
|
export class DateTransformer implements ValueTransformer {
|
|
6
6
|
to(value: Date | string): string {
|
|
7
|
-
const result = moment(value).format(
|
|
8
|
-
return result
|
|
7
|
+
const result = moment(value).format("YYYY-MM-DD HH:mm:ss");
|
|
8
|
+
return result;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
from(value: string): string {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return result
|
|
11
|
+
from(value: string): Date | null | string {
|
|
12
|
+
if (value === null) return null;
|
|
13
|
+
|
|
14
|
+
const result = moment.utc(value).tz(getTimeZone()).toDate();
|
|
15
|
+
return result;
|
|
17
16
|
}
|
|
18
17
|
}
|