feat: date range status function added

This commit is contained in:
Anmol Singh Bhatia 2023-03-03 11:32:00 +05:30
parent 8a941d0d14
commit 02e4e58f19
3 changed files with 18 additions and 34 deletions

View file

@ -88,3 +88,17 @@ export const timeAgo = (time: any) => {
}
return time;
};
export const getDateRangeStatus = (startDate: string , endDate: string ) => {
const now = new Date();
const start = new Date(startDate);
const end = new Date(endDate);
if (end < now) {
return "past";
} else if (start <= now && end >= now) {
return "current";
} else {
return "upcoming";
}
}