mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 14:06:27 +00:00
fix(client): compute "today" from the local calendar, not UTC
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { localIsoDate } from '../../utils/localDate';
|
||||
import { act, fireEvent, render, screen } from '../../../tests/helpers/render';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import { CustomDatePicker, CustomDateTimePicker } from './CustomDateTimePicker';
|
||||
@@ -722,7 +723,7 @@ describe('CustomDateTimePicker branches', () => {
|
||||
const steppers = screen.getAllByRole('button').filter((b) => b.textContent?.trim() === '');
|
||||
fireEvent.click(steppers[steppers.length - 4]);
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const today = localIsoDate(); // the picker falls back to the LOCAL date, not the UTC one
|
||||
expect(onChange).toHaveBeenCalledWith(`${today}T01:00`);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Calendar, ChevronLeft, ChevronRight, Keyboard } from 'lucide-react';
|
||||
import { localIsoDate } from '../../utils/localDate';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useTranslation } from '../../i18n';
|
||||
@@ -688,7 +689,7 @@ export function CustomDateTimePicker({ value, onChange, placeholder, style = {}
|
||||
onChange(d ? `${d}T${timePart || '12:00'}` : '');
|
||||
};
|
||||
const handleTimeChange = (t: string) => {
|
||||
const d = datePart || new Date().toISOString().split('T')[0];
|
||||
const d = datePart || localIsoDate();
|
||||
onChange(t ? `${d}T${t}` : d);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user