Skip to content

Commit

Permalink
fix(api): using timestamptz type for Dates in Entities
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Jan 12, 2019
1 parent 8ae9100 commit e0760a7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/app/auth/user.entity.ts
Expand Up @@ -41,10 +41,10 @@ export class User extends Base {
@Column()
userId: string;

@CreateDateColumn()
@CreateDateColumn({ type: 'timestamptz' })
createdAt?: Date;

@UpdateDateColumn()
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt?: Date;

@VersionColumn()
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/core/entities/audit-base.entity.ts
Expand Up @@ -13,12 +13,12 @@ export abstract class AuditBase {

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
// @Exclude()
@CreateDateColumn()
@CreateDateColumn({ type: 'timestamptz' })
createdAt?: Date;

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
// @Exclude()
@UpdateDateColumn()
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt?: Date;

// @Exclude()
Expand Down
Expand Up @@ -66,11 +66,11 @@ export class Notification extends Base {
isActive?: boolean;

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
@CreateDateColumn()
@CreateDateColumn({ type: 'timestamptz' })
createdAt?: Date;

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
@UpdateDateColumn()
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt?: Date;

@Exclude()
Expand Down
Expand Up @@ -28,11 +28,11 @@ export class Subscription extends Base {
topics: string[];

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
@CreateDateColumn()
@CreateDateColumn({ type: 'timestamptz' })
createdAt?: Date;

@ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' })
@UpdateDateColumn()
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt?: Date;

@Exclude()
Expand Down
2 changes: 1 addition & 1 deletion libs/ngx-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@ngx-starter-kit/ngx-utils",
"version": "0.0.2",
"version": "0.0.3",
"peerDependencies": {
"@angular/common": ">=6.0.0 <8.0.0",
"@angular/core": ">=6.0.0 <8.0.0",
Expand Down
Expand Up @@ -74,10 +74,6 @@ export class FormatTimeInWordsPipe implements PipeTransform, OnDestroy {

private stringToDate(date: string | number | Date): number | Date {
const isString = s => typeof(s) === 'string' || s instanceof String;
console.log(date);
console.log(new Date(date as string));
console.log(new Date(Date.parse(date as string)));

return isString(date) ? parseISO(date) : date;
}
}

0 comments on commit e0760a7

Please sign in to comment.