Skip to content

Commit 0ea2622

Browse files
authored
refactor(client-side-validation): use toISOString (#562)
1 parent f92af84 commit 0ea2622

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

client-side-validation/app/routes/_index.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@ export const loader = async () => {
2626
const date = new Date();
2727

2828
// today string in "YYYY-MM-DD" format
29-
const todayString = `${date.getFullYear()}-${(
30-
"00" +
31-
(date.getMonth() + 1)
32-
).slice(-2)}-${("00" + date.getDate()).slice(-2)}`;
29+
const todayString = date.toISOString().substring(0, 10);
30+
31+
date.setDate(date.getDate() + 1)
3332

3433
// tomorrow string in "YYYY-MM-DD" format
35-
const tomorrowString = `${date.getFullYear()}-${(
36-
"00" +
37-
(date.getMonth() + 1)
38-
).slice(-2)}-${("00" + (date.getDate() + 1)).slice(-2)}`;
34+
const tomorrowString = date.toISOString().substring(0, 10);
3935

4036
return json({ todayString, tomorrowString });
4137
};

0 commit comments

Comments
 (0)