mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-22 10:51:46 +03:00
1ec736b357
* feat(brainSettings): add feed process instrcution to knowledge tab * feat: prevent default brain auto fetch * feat: prevent chat submision on submit button click * feat: remove unrelevant toast * feat: remove duplicated GA initialization * feat: add brain name in notifications * fix(test): update analytics import path * refactor: move ChatsList utils to ChatsList directory * fix(test): update chatlist tests
32 lines
793 B
TypeScript
32 lines
793 B
TypeScript
export const isToday = (date: Date): boolean => {
|
|
const today = new Date();
|
|
|
|
return date.toDateString() === today.toDateString();
|
|
};
|
|
|
|
export const isYesterday = (date: Date): boolean => {
|
|
const yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
return date.toDateString() === yesterday.toDateString();
|
|
};
|
|
|
|
export const isWithinLast7Days = (date: Date): boolean => {
|
|
const weekAgo = new Date();
|
|
weekAgo.setDate(weekAgo.getDate() - 7);
|
|
|
|
return date > weekAgo && !isToday(date) && !isYesterday(date);
|
|
};
|
|
|
|
export const isWithinLast30Days = (date: Date): boolean => {
|
|
const monthAgo = new Date();
|
|
monthAgo.setDate(monthAgo.getDate() - 30);
|
|
|
|
return (
|
|
date > monthAgo &&
|
|
!isToday(date) &&
|
|
!isYesterday(date) &&
|
|
!isWithinLast7Days(date)
|
|
);
|
|
};
|