Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hooks/useCourseData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function useCourseData(courses: any[]) {
setIsPending(false);
} catch (error) {
localStorage.removeItem('lastRequestTime');
// setIsError(true);
setIsError(true);
setIsPending(false);
}
}, [courses]);
Expand Down
14 changes: 12 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

export function isCurrentDateInRange(dateRange: string) {
export function isCurrentDateInRange(dateRange: string | null) {
if (!dateRange || !dateRange.includes(' ~ ')) {
return false;
}

const [startStr, endStr] = dateRange.split(' ~ ');

if (!startStr || !endStr) {
return false;
}

const startDate = new Date(startStr.replace(/-/g, '/'));
const endDate = new Date(endStr.replace(/-/g, '/'));

const currentDate = new Date();

return currentDate >= startDate && currentDate <= endDate;
}
export function isCurrentDateByDate(date: string) {

export function isCurrentDateByDate(date: string | null) {
if (!date || date.length <= 1) return false;
const endDate = new Date(date);
const currentDate = new Date();
return currentDate <= endDate;
Expand Down
Loading