* UI initialization * feat: structure API * feat: audience & people analytics * feat: quick changes * feat: add comments * redesign course student page * chore: make requests to db more efficient * clean up analytics page for course * feat: finish up audience analytics page * chore: minor UI tweaks * translate all * replace inserts of log in events to update * catch error if last_login isn't inserted --------- Co-authored-by: Rotimi Best <best@classroomio.com>
19 lines
475 B
TypeScript
19 lines
475 B
TypeScript
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`;
|
|
};
|
|
|
|
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';
|
|
};
|