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

19 lines
391 B
TypeScript
Raw Normal View History

2021-04-26 11:27:44 +02:00
import { User } from './user.model';
2020-05-05 18:17:12 +02:00
export class Comment {
2021-04-26 17:04:16 +02:00
constructor(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
}