Skip to content

Commit

Permalink
Replace YYYY-MM-DD by the constant DATE_FORMAT
Browse files Browse the repository at this point in the history
  • Loading branch information
onesine committed Apr 22, 2023
1 parent 82790be commit 61e8bf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Input: React.FC<Props> = (e: Props) => {

const border = BORDER_COLOR.focus[primaryColor as keyof typeof BORDER_COLOR.focus];
const ring =
RING_COLOR["second-focus"][primaryColor as keyof typeof RING_COLOR["second-focus"]];
RING_COLOR["second-focus"][primaryColor as keyof (typeof RING_COLOR)["second-focus"]];

const defaultInputClassName = `relative transition-all duration-300 py-2.5 pl-4 pr-14 w-full border-gray-300 dark:bg-slate-800 dark:text-white/80 dark:border-slate-600 rounded-lg tracking-wide font-light text-sm placeholder-gray-400 bg-white focus:ring disabled:opacity-40 disabled:cursor-not-allowed ${border} ${ring}`;

Expand All @@ -69,12 +69,12 @@ const Input: React.FC<Props> = (e: Props) => {
const inputValue = e.target.value;

const start = parseFormattedDate(inputValue.slice(0, 10), displayFormat).format(
"YYYY-MM-DD"
DATE_FORMAT
);
const end = asSingle
? start
: parseFormattedDate(inputValue.slice(11, inputValue.length), displayFormat).format(
"YYYY-MM-DD"
DATE_FORMAT
);

const input = inputRef?.current;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function formatDate(date: dayjs.Dayjs, format = DATE_FORMAT) {
return date.format(format);
}

export function parseFormattedDate(date: string, format = "YYYY-MM-DD") {
export function parseFormattedDate(date: string, format = DATE_FORMAT) {
return dayjs(date, format);
}

Expand Down

0 comments on commit 61e8bf0

Please sign in to comment.