test-entity-library-asm 3.9.15 → 3.9.17

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
1
  import { ValueTransformer } from "typeorm";
2
2
  export declare class DateTransformer implements ValueTransformer {
3
3
  to(value: Date | string): string;
4
- from(value: string): Date | null;
4
+ from(value: string): Date | null | string;
5
5
  }
@@ -7,19 +7,15 @@ exports.DateTransformer = void 0;
7
7
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
8
8
  const __1 = require("..");
9
9
  class DateTransformer {
10
- // Cuando guardamos en DB
11
10
  to(value) {
12
- // Guardamos en UTC puro
13
- return (0, moment_timezone_1.default)(value).utc().format("YYYY-MM-DD HH:mm:ss");
11
+ const result = (0, moment_timezone_1.default)(value).format("YYYY-MM-DD HH:mm:ss");
12
+ return result;
14
13
  }
15
- // Cuando leemos de DB
16
14
  from(value) {
17
- if (!value)
15
+ if (value === null)
18
16
  return null;
19
- const tz = (0, __1.getTimeZone)(); // Ej: "America/Bogota"
20
- // Interpretamos el valor como UTC y luego lo convertimos a tz del usuario
21
- const m = moment_timezone_1.default.tz(value, "YYYY-MM-DD HH:mm:ss", "UTC").tz(tz, true);
22
- return m.toDate();
17
+ const result = moment_timezone_1.default.utc(value).tz((0, __1.getTimeZone)()).toDate();
18
+ return result;
23
19
  }
24
20
  }
25
21
  exports.DateTransformer = DateTransformer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "3.9.15",
3
+ "version": "3.9.17",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -168,7 +168,7 @@ export class Local {
168
168
 
169
169
  @OneToMany(
170
170
  () => LocalQualification,
171
- (localQualification) => localQualification.local
171
+ (localQualification) => localQualification.local,
172
172
  )
173
173
  qualifications: LocalQualification[];
174
174
 
@@ -188,7 +188,7 @@ export class Local {
188
188
 
189
189
  @ManyToMany(
190
190
  () => BusinessTypeProduct,
191
- (businessTypeProduct) => businessTypeProduct.business_type_products
191
+ (businessTypeProduct) => businessTypeProduct.business_type_products,
192
192
  )
193
193
  @JoinTable({
194
194
  name: "business_type_product_local",
@@ -205,7 +205,7 @@ export class Local {
205
205
 
206
206
  @OneToMany(
207
207
  () => DiscountCodeUser,
208
- (discountCodeUser) => discountCodeUser.local
208
+ (discountCodeUser) => discountCodeUser.local,
209
209
  )
210
210
  discount_code_locals: DiscountCodeUser[];
211
211
 
@@ -223,13 +223,13 @@ export class Local {
223
223
 
224
224
  @OneToMany(
225
225
  () => LocalDecorationReserve,
226
- (localDecorationReserve) => localDecorationReserve.local
226
+ (localDecorationReserve) => localDecorationReserve.local,
227
227
  )
228
228
  local_decorations_reserve: LocalDecorationReserve[];
229
229
 
230
230
  @OneToMany(
231
231
  () => LocalReserveStatus,
232
- (localReserveStatus) => localReserveStatus.local
232
+ (localReserveStatus) => localReserveStatus.local,
233
233
  )
234
234
  local_reserve_status: LocalReserveStatus[];
235
235
 
@@ -241,7 +241,7 @@ export class Local {
241
241
 
242
242
  @OneToMany(
243
243
  () => LocalPaymentMethod,
244
- (localPaymentMethod) => localPaymentMethod.local
244
+ (localPaymentMethod) => localPaymentMethod.local,
245
245
  )
246
246
  locals_payment_method: LocalPaymentMethod[];
247
247
  }
@@ -3,19 +3,15 @@ import moment from "moment-timezone";
3
3
  import { getTimeZone } from "..";
4
4
 
5
5
  export class DateTransformer implements ValueTransformer {
6
- // Cuando guardamos en DB
7
6
  to(value: Date | string): string {
8
- // Guardamos en UTC puro
9
- return moment(value).utc().format("YYYY-MM-DD HH:mm:ss");
7
+ const result = moment(value).format("YYYY-MM-DD HH:mm:ss");
8
+ return result;
10
9
  }
11
10
 
12
- // Cuando leemos de DB
13
- from(value: string): Date | null {
14
- if (!value) return null;
11
+ from(value: string): Date | null | string {
12
+ if (value === null) return null;
15
13
 
16
- const tz = getTimeZone(); // Ej: "America/Bogota"
17
- // Interpretamos el valor como UTC y luego lo convertimos a tz del usuario
18
- const m = moment.tz(value, "YYYY-MM-DD HH:mm:ss", "UTC").tz(tz, true);
19
- return m.toDate();
14
+ const result = moment.utc(value).tz(getTimeZone()).toDate();
15
+ return result;
20
16
  }
21
17
  }