Skip to content

Commit

Permalink
fix: use date-fns functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackySoul committed Nov 5, 2024
1 parent 3e69bfc commit 7f7aa49
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/vkui/src/components/DateInput/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from 'react';
import { Icon16Clear, Icon20CalendarOutline } from '@vkontakte/icons';
import { classNames } from '@vkontakte/vkjs';
import { startOfDay, startOfMinute } from 'date-fns';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import { useDateInput } from '../../hooks/useDateInput';
import { useExternRef } from '../../hooks/useExternRef';
Expand Down Expand Up @@ -175,13 +176,9 @@ export const DateInput = ({
}

if (isMatch(formattedValue, mask)) {
const now = new Date();
onChange?.(
parse(
formattedValue,
mask,
value ??
new Date(enableTime ? new Date().setSeconds(0, 0) : new Date().setHours(0, 0, 0, 0)),
),
parse(formattedValue, mask, value ?? (enableTime ? startOfMinute(now) : startOfDay(now))),
);
}
},
Expand Down

0 comments on commit 7f7aa49

Please sign in to comment.