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

15 lines
455 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();
2024-04-19 05:45:48 +01:00
return hours < 12 ? 'dashboard.morning_heading' : hours < 18 ? 'dashboard.afternoon_heading' : 'dashboard.evening_heading';
2023-10-22 09:47:13 +01:00
};