Updates date style on tasks page (#1244)

* updates date style on tasks page

* re-run tests
This commit is contained in:
Srikar Samudrala
2023-08-18 01:19:09 +05:30
committed by GitHub
parent f4accc66fa
commit cf1dfb8c42
3 changed files with 77 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { formatDistanceToNow } from 'date-fns';
import { differenceInCalendarDays, formatDistanceToNow } from 'date-fns';
import { DateTime } from 'luxon';
import { logError } from './logError';
@ -88,3 +88,19 @@ export function beautifyPastDateAbsolute(pastDate: Date | string | number) {
return '';
}
}
export function hasDatePassed(date: Date | string | number) {
try {
const parsedDate = parseDate(date);
return (
differenceInCalendarDays(
DateTime.local().toJSDate(),
parsedDate.toJSDate(),
) >= 1
);
} catch (error) {
logError(error);
return false;
}
}