Skip to content

Commit

Permalink
fix(slash): correct issue with formatDateValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley NARRAINEN committed Jan 15, 2025
1 parent aba40e4 commit e7ebed9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions slash/react/src/Form/Date/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ type Props = Omit<ComponentPropsWithRef<"input">, "value"> & {
};

const formatDateValue = (dateValue: Date) => {
const monthFormatted = `0${dateValue.getMonth() + 1}`.slice(-2);
const dayFormatted = `0${dateValue.getDate()}`.slice(-2);
return `${dateValue.getFullYear()}-${monthFormatted}-${dayFormatted}`;
const formattedDateValue = new globalThis.Date(dateValue);
const monthFormatted = `0${formattedDateValue.getMonth() + 1}`.slice(-2);
const dayFormatted = `0${formattedDateValue.getDate()}`.slice(-2);
return `${formattedDateValue.getFullYear()}-${monthFormatted}-${dayFormatted}`;
};

const Date = forwardRef<HTMLInputElement, Props>(
Expand Down

0 comments on commit e7ebed9

Please sign in to comment.