Files
classroomio/apps/dashboard/src/lib/utils/functions/date.ts
T

19 lines
475 B
TypeScript
Raw Normal View History

import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
export const calDateDiff = (date: string | number | Date): string => {
return dayjs(date).fromNow(true) + ` ago`;
};
2023-10-22 09:47:13 +01:00
export const getGreeting = () => {
const date = new Date();
const hours = date.getHours();
return hours < 12
? 'dashboard.morning_heading'
: hours < 18
? 'dashboard.afternoon_heading'
: 'dashboard.evening_heading';
2023-10-22 09:47:13 +01:00
};