key created_at for comment, format date

This commit is contained in:
Tykayn 2021-04-27 10:48:29 +02:00 committed by tykayn
parent e45b490c2f
commit 2d3457cf6f
4 changed files with 10 additions and 6 deletions

View File

@ -1,7 +1,5 @@
import { User } from './user.model';
export class Comment {
constructor(public text: string, public pseudo: string, public created_at: string) {}
constructor(public id: string, public text: string, public pseudo: string, public created_at: string) {}
public static sortChronologically(first: Comment, second: Comment): number {
const a = new Date(first.created_at);

View File

@ -67,10 +67,12 @@
<p>
<em class="cname"> {{ comment.pseudo }} </em>,
<span class="date-days-ago is-small">
<span class="date date-days-ago">
il y a
{{ calculateDaysAgoOfComment(comment.date.date) }} jours, le </span
><span class="date is-small"> {{ comment.date.date }} </span>
{{ calculateDaysAgoOfComment(comment.created_at) }} jours, le </span
><span class="date is-small">
{{ comment.created_at | date: 'short':'Europe/Paris':'fr_FR' }}
</span>
</p>
</div>
<div class="message-body">

View File

@ -0,0 +1,3 @@
.date {
font-size: 0.85em;
}

View File

@ -17,6 +17,7 @@ export class CommentsComponent {
};
constructor(private pollService: PollService) {}
calculateDaysAgoOfComment(dateAsString) {
let numberOfDays = 0;