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 'typeorm';
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('YYYY-MM-DD HH:mm:ss');
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
- var result = moment
15
- .utc(value)
16
- .tz((0, __1.getTimeZone)())
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,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "3.3.5",
3
+ "version": "3.3.6",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,18 +1,17 @@
1
- import { ValueTransformer } from 'typeorm'
2
- import * as moment from 'moment-timezone'
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('YYYY-MM-DD HH:mm:ss')
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
- const result = moment
13
- .utc(value)
14
- .tz(getTimeZone())
15
- .format('YYYY-MM-DD HH:mm:ss')
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
  }