Co-authored-by: pdf114514 <57948770+pdf114514@users.noreply.github.com> Agent-Logs-Url: https://github.com/pdf114514/CarReservation/sessions/6d0f25ae-6db4-4937-ae2b-6674456a5ca1
14 lines
487 B
JavaScript
14 lines
487 B
JavaScript
/**
|
|
* Returns true if the given inspection expiry date string is within 1 month
|
|
* from today (or already past).
|
|
* @param {string} inspectionExpiry - ISO date string (YYYY-MM-DD) or empty
|
|
* @returns {boolean}
|
|
*/
|
|
export function isInspectionExpirySoon(inspectionExpiry) {
|
|
if (!inspectionExpiry) return false;
|
|
const expiry = new Date(inspectionExpiry);
|
|
const oneMonthLater = new Date();
|
|
oneMonthLater.setMonth(oneMonthLater.getMonth() + 1);
|
|
return expiry <= oneMonthLater;
|
|
}
|