Skip to content

Commit

Permalink
[@mantine/dates] DateTimePicker: Fix timezone conversion being applie…
Browse files Browse the repository at this point in the history
…d twice (#7400)
  • Loading branch information
mrbnclt authored Jan 26, 2025
1 parent c2920f1 commit f7347e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ describe('@mantine/dates/DateTimePicker', () => {
/>
</DatesProvider>
);
expectValue(container, '01/02/2022 09:00 +00:00');
expectValue(container, '01/02/2022 04:00 +00:00');

await clickInput(container);
await userEvent.click(container.querySelectorAll('table button')[6]);
expectValue(container, '06/02/2022 09:00 +00:00');
expectValue(container, '06/02/2022 04:00 +00:00');

await userEvent.clear(getTimeInput());
await userEvent.type(getTimeInput(), '14:45');
expectValue(container, '06/02/2022 19:45 +00:00');
expectValue(container, '06/02/2022 14:45 +00:00');
});

it('supports controlled state', async () => {
Expand Down Expand Up @@ -229,11 +229,11 @@ describe('@mantine/dates/DateTimePicker', () => {
/>
</DatesProvider>
);
expectValue(container, '01/02/2022 09:00 +00:00');
expectValue(container, '01/02/2022 04:00 +00:00');

await clickInput(container);
await userEvent.click(container.querySelectorAll('table button')[6]);
expectValue(container, '01/02/2022 09:00 +00:00');
expectValue(container, '01/02/2022 04:00 +00:00');
expect(spy).toHaveBeenLastCalledWith(new Date(2022, 1, 5, 23));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const DateTimePicker = factory<DateTimePickerFactory>((_props, ref) => {

const [dropdownOpened, dropdownHandlers] = useDisclosure(false);
const formattedValue = _value
? dayjs(_value).locale(ctx.getLocale(locale)).tz(ctx.getTimezone()).format(_valueFormat)
? dayjs(_value).locale(ctx.getLocale(locale)).tz(ctx.getTimezone(), true).format(_valueFormat)
: '';

const handleTimeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down

0 comments on commit f7347e9

Please sign in to comment.