Skip to content

Commit

Permalink
fix: set hour to 0 when its not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakbarazizi committed Oct 5, 2023
1 parent 03a9a85 commit f7d6ea9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/components/datepicker/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type InputProps<
* Parse the value of input when changed to Date
* It will be ignored if the format value is not function.
*
* If you don't provide this and format value is function the input will be readonly
* If you don't provide this and format value is a function the input will be readonly
*
* @param date
* @param currentDate the current value of the Date it usefull to use it for reference in parse
Expand Down Expand Up @@ -117,7 +117,7 @@ export const Input = forwardRef(
state.onChange(parseValue);
}

setDirtyInputValue(undefined);
disposables.nextFrame(() => setDirtyInputValue(undefined));
});

const readOnly =
Expand Down
20 changes: 0 additions & 20 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ export const config: DatepickerConfig = {
format: (date, format) => (date ? dateFromat(date, format) : ''),
parse: (date, format, referenceDate) => {
const parseDate = parse(date, format, referenceDate || new Date());
/**
* Since date-fns is not always use referenceDate as reference
* We need to make sure the of that.
*
*
* 'Parse use reference date only in rare cases we need to make sure it work'
* @see https://github.com/date-fns/date-fns/issues/1838#issuecomment-696674141
*/
if (referenceDate) {
parseDate.setUTCSeconds(
referenceDate.getUTCSeconds(),
referenceDate.getMilliseconds(),
);
if (!format.match(/H|h|K|k/)) {
parseDate.setUTCHours(referenceDate.getUTCHours());
}
if (!format.match(/m/)) {
parseDate.setUTCMinutes(referenceDate.getUTCMinutes());
}
}

return parseDate;
},
Expand Down

0 comments on commit f7d6ea9

Please sign in to comment.