funky-framadate-front/src/app/core/models/comment.model.ts

21 lines
436 B
TypeScript
Raw Normal View History

2022-02-14 14:37:42 +01:00
export interface CommentDTO {
pseudo: string;
text: string;
}
2020-05-05 18:17:12 +02:00
export class Comment {
constructor(public id: string, public text: string, public pseudo: string, public created_at: string) {}
2021-04-26 11:27:44 +02:00
public static sortChronologically(first: Comment, second: Comment): number {
const a = new Date(first.created_at);
const b = new Date(second.created_at);
2020-05-12 19:16:23 +02:00
2021-04-26 11:27:44 +02:00
if (a < b) {
2020-05-12 19:16:23 +02:00
return -1;
}
2021-04-26 11:27:44 +02:00
if (a > b) {
2020-05-12 19:16:23 +02:00
return 1;
}
return 0;
}
2020-05-05 18:17:12 +02:00
}