Changeset View
Changeset View
Standalone View
Standalone View
src/app/_models/comment.ts
import {Author} from './author'; | import {Author} from './author'; | ||||
export class Comment { | export class Comment { | ||||
public created: Date; | |||||
static parse(obj: any) { | static parse(obj: any) { | ||||
return new Comment( | return new Comment( | ||||
obj.id, | obj.id, | ||||
obj.author, | obj.author, | ||||
obj.created, | obj.created, | ||||
obj.text, | obj.text, | ||||
obj.image | obj.image | ||||
); | ); | ||||
} | } | ||||
constructor( | constructor( | ||||
public id: number, | public id: number, | ||||
public author: Author, | public author: Author, | ||||
created: string, | public created: string, | ||||
public text: string, | public text: string, | ||||
public image: string | public image: string | ||||
) { | ) { | ||||
this.created = new Date(created); | const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' }; | ||||
const time = new Date(created); | |||||
this.created = time.toLocaleDateString(undefined, options); | |||||
} | } | ||||
getError(): CommentError { | getError(): CommentError { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
export class CommentError extends Comment { | export class CommentError extends Comment { | ||||
Show All 11 Lines |