significantly improved datepicker

This commit is contained in:
2025-01-25 22:50:35 -05:00
parent 896c6640e2
commit c9c6650829
6 changed files with 152 additions and 111 deletions

View File

@ -0,0 +1,37 @@
import moment from "moment";
const convertAniListDateToString = (date: {
year?: number;
month?: number;
day?: number;
}): string => {
if (
date.year === undefined ||
(date.year === 0 && date.month === undefined) ||
(date.month === 0 && date.day === undefined) ||
date.day === 0
) {
return "";
}
const newISODate = new Date(date.year, date.month - 1, date.day);
const newMoment = moment(newISODate);
return newMoment.format("MM-DD-YYYY");
};
const convertAniListDateToDate = (date: {
year?: number;
month?: number;
day?: number;
}): Date | null => {
if (
date.year === undefined ||
(date.year === 0 && date.month === undefined) ||
(date.month === 0 && date.day === undefined) ||
date.day === 0
) {
return null;
}
return new Date(date.year, date.month - 1, date.day);
};
export { convertAniListDateToString, convertAniListDateToDate };