Fix changeover

This commit is contained in:
Nicolas Mowen 2024-03-30 08:37:08 -06:00
parent 09e8266aee
commit 5ce49b9a43
2 changed files with 14 additions and 15 deletions

View File

@ -308,19 +308,18 @@ function CustomTimeSelector({
const timezoneOffset = useMemo(
() =>
/*
config?.ui.timezone
? getUTCOffset(new Date(), config.ui.timezone)
: undefined
*/
getUTCOffset(new Date(), "Australia/Darwin"),
[],
config?.ui.timezone
? Math.round(getUTCOffset(new Date(), config.ui.timezone))
: undefined,
[config?.ui.timezone],
);
const localTimeOffset = useMemo(
() =>
getUTCOffset(
new Date(),
Intl.DateTimeFormat().resolvedOptions().timeZone,
Math.round(
getUTCOffset(
new Date(),
Intl.DateTimeFormat().resolvedOptions().timeZone,
),
),
[],
);
@ -398,7 +397,7 @@ function CustomTimeSelector({
</PopoverTrigger>
<PopoverContent className="flex flex-col items-center">
<TimezoneAwareCalendar
timezone={"Australia/Darwin"}
timezone={config?.ui.timezone}
selectedDay={new Date(startTime * 1000)}
onSelect={(day) => {
if (!day) {
@ -460,7 +459,7 @@ function CustomTimeSelector({
</PopoverTrigger>
<PopoverContent className="flex flex-col items-center">
<TimezoneAwareCalendar
timezone={"Australia/Darwin"}
timezone={config?.ui.timezone}
selectedDay={new Date(endTime * 1000)}
onSelect={(day) => {
if (!day) {

View File

@ -89,7 +89,8 @@ export function TimezoneAwareCalendar({
onSelect,
}: TimezoneAwareCalendarProps) {
const timezoneOffset = useMemo(
() => (timezone ? getUTCOffset(new Date(), timezone) : undefined),
() =>
timezone ? Math.round(getUTCOffset(new Date(), timezone)) : undefined,
[timezone],
);
const disabledDates = useMemo(() => {
@ -102,7 +103,6 @@ export function TimezoneAwareCalendar({
0,
0,
);
tomorrow.setHours(25);
} else {
tomorrow.setHours(tomorrow.getHours() + 24, -1, 0, 0);
}
@ -127,7 +127,7 @@ export function TimezoneAwareCalendar({
date.getUTCSeconds(),
);
const todayUtc = new Date(utc);
todayUtc.setHours(25, todayUtc.getMinutes() + timezoneOffset, 0, 0);
todayUtc.setMinutes(todayUtc.getMinutes() + timezoneOffset, 0, 0);
return todayUtc;
}, [timezoneOffset]);