2023-10-02 04:15:01 +01:00
|
|
|
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 ? 'Good Morning' : hours < 18 ? 'Good Afternoon' : 'Good Evening';
|
|
|
|
|
};
|