Skip to content

Commit 402874a

Browse files
kraillerjquense
authored andcommittedJan 15, 2020
fix: date strings before 1970 too (#748)
1 parent 7036522 commit 402874a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/date.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function DateSchema() {
2121
if (this.isType(value)) return value;
2222

2323
value = isoParse(value);
24-
// 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch)
25-
return value > -1 ? new Date(value) : invalidDate;
24+
// 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
25+
return !isNaN(value) ? new Date(value) : invalidDate;
2626
});
2727
});
2828
}

0 commit comments

Comments
 (0)
Please sign in to comment.