Skip to content

Commit

Permalink
refactor(client-side-validation): use toISOString (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbultman authored Jan 10, 2025
1 parent f92af84 commit 0ea2622
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client-side-validation/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ export const loader = async () => {
const date = new Date();

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

date.setDate(date.getDate() + 1)

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

return json({ todayString, tomorrowString });
};
Expand Down

0 comments on commit 0ea2622

Please sign in to comment.