Convert times to/from UTC

This commit is contained in:
jude
2024-02-26 10:26:07 +00:00
parent 5f6326179c
commit 45f5b6261a
6 changed files with 25 additions and 34 deletions

View File

@ -7,11 +7,13 @@ import { useReminder } from "./ReminderContext";
import { Attachment } from "./Attachment";
import { TTS } from "./TTS";
import { TimeInput } from "./TimeInput";
import { useTimezone } from "../App/TimezoneProvider";
export const Settings = () => {
const { isSuccess: userFetched, data: userInfo } = useQuery(fetchUserInfo());
const [reminder, setReminder] = useReminder();
const [timezone] = useTimezone();
if (!userFetched) {
return <></>;
@ -41,11 +43,11 @@ export const Settings = () => {
<label class="label collapses">
Time*
<TimeInput
defaultValue={reminder.utc_time}
defaultValue={reminder.utc_time.setZone(timezone)}
onInput={(time: DateTime) => {
setReminder((reminder) => ({
...reminder,
utc_time: time,
utc_time: time.toUTC(),
}));
}}
/>
@ -96,11 +98,11 @@ export const Settings = () => {
<label class="label">
Expiration
<TimeInput
defaultValue={reminder.expires}
defaultValue={reminder.expires?.setZone(timezone)}
onInput={(time: DateTime) => {
setReminder((reminder) => ({
...reminder,
expires: time,
expires: time?.toUTC(),
}));
}}
/>

View File

@ -35,7 +35,7 @@ export const TimeInput = ({ defaultValue, onInput }) => {
}
flash({
message: `Couldn't parse your clipboard data as a valid date-time`,
message: "Couldn't parse your clipboard data as a valid date-time",
type: "error",
});
}}