fix comments

This commit is contained in:
Philipinho
2023-11-22 12:54:45 +00:00
parent 7b91b6d642
commit eb95a619db
11 changed files with 118 additions and 125 deletions
-5
View File
@@ -1,5 +0,0 @@
import { formatDistanceStrict } from 'date-fns';
export function timeAgo(date: Date){
return formatDistanceStrict(new Date(date), new Date(), { addSuffix: true })
}
+16
View File
@@ -0,0 +1,16 @@
import { formatDistanceStrict } from 'date-fns';
import { format, isToday, isYesterday } from 'date-fns';
export function timeAgo(date: Date) {
return formatDistanceStrict(new Date(date), new Date(), { addSuffix: true });
}
export function formatDate(date: Date) {
if (isToday(date)) {
return `Today, ${format(date, 'h:mma')}`;
} else if (isYesterday(date)) {
return `Yesterday, ${format(date, 'h:mma')}`;
} else {
return format(date, 'MMM dd, yyyy, h:mma');
}
}