Skip to content

Commit c95b6a7

Browse files
committed
[Bug]: Invalid leap day (2100-02-29) accepted and converted to timestamp.
1 parent da5c57d commit c95b6a7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

client/src/pages/tools/date-converter.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ export default function DateConverter() {
183183

184184
// Try standard date parsing
185185
const date = new Date(input);
186+
if (/^\d{4}-\d{2}-\d{2}$/.test(input)) {
187+
const [y, m, d] = input.split("-").map(Number);
188+
189+
if (
190+
date.getUTCFullYear() !== y ||
191+
date.getUTCMonth() + 1 !== m ||
192+
date.getUTCDate() !== d
193+
) {
194+
return null;
195+
}
196+
}
186197
return isNaN(date.getTime()) ? null : date;
187198
};
188199

0 commit comments

Comments
 (0)