Skip to content

Commit

Permalink
Cover edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
CiprianS committed Jun 6, 2023
1 parent 21b07a6 commit af7e403
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/isDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ export default function isDate(input, options) {
let fullYear = dateObj.y;

if (dateObj.y.length === 2) {
const parsedYear = parseInt(dateObj.y, 10);

if (isNaN(parsedYear)) {
return false;
}

const currentYearLastTwoDigits = new Date().getFullYear() % 100;

if (parseInt(dateObj.y, 10) < currentYearLastTwoDigits) {
if (parsedYear < currentYearLastTwoDigits) {
fullYear = `20${dateObj.y}`;
} else {
fullYear = `19${dateObj.y}`;
Expand Down

0 comments on commit af7e403

Please sign in to comment.