Fix bugs with time picker

* Load UTC time correctly at page load
* Don't translate to/from timezone when using the browser date/time
  input
This commit is contained in:
jude 2024-04-16 12:44:19 +01:00
parent 1cf707140c
commit 1d06999e41
2 changed files with 3 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import { useQuery } from "react-query";
import "./styles.scss";
import { useGuild } from "../App/useGuild";
import { DEFAULT_COLOR } from "./Embed";
import { useTimezone } from "../App/TimezoneProvider";
function defaultReminder(): Reminder {
return {
@ -38,7 +39,7 @@ function defaultReminder(): Reminder {
tts: false,
uid: "",
username: "",
utc_time: DateTime.now().toFormat("yyyy-LL-dd'T'HH:mm:ss"),
utc_time: DateTime.now().setZone("UTC").toFormat("yyyy-LL-dd'T'HH:mm:ss"),
};
}

View File

@ -284,11 +284,7 @@ export const TimeInput = ({ defaultValue, onInput }) => {
onInput={(ev) => {
ev.currentTarget.value === ""
? updateTime(null)
: setTime(
DateTime.fromISO(ev.currentTarget.value, { zone: timezone }).setZone(
"UTC",
),
);
: setTime(DateTime.fromISO(ev.currentTarget.value, { zone: "UTC" }));
}}
></input>
</>