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

View File

@ -35,7 +35,7 @@ export const TimeInput = ({ defaultValue, onInput }) => {
} }
flash({ 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", type: "error",
}); });
}} }}

View File

@ -12,7 +12,15 @@ export const MobileSidebar = ({ children }) => {
> >
<div class="navbar-brand"> <div class="navbar-brand">
<a class="navbar-item" href="/"> <a class="navbar-item" href="/">
<figure class="image"> <figure
class="image"
style={{
maxWidth: "28px",
maxHeight: "28px",
overflow: "hidden",
display: "flex",
}}
>
<img <img
width="28px" width="28px"
height="28px" height="28px"

View File

@ -23,30 +23,7 @@ const SidebarContent = ({ guilds }: ContentProps) => {
<Wave /> <Wave />
<aside class="menu"> <aside class="menu">
<p class="menu-label">Servers</p> <p class="menu-label">Servers</p>
<ul class="menu-list guildList"> <ul class="menu-list guildList">{guildEntries}</ul>
{guildEntries}
<GuildEntry guild={{ id: "1", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "2", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "3", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "4", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "5", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "6", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "7", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "8", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "9", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
<GuildEntry guild={{ id: "10", name: "1", patreon: false }} />
</ul>
<div class="aside-footer"> <div class="aside-footer">
<p class="menu-label">Options</p> <p class="menu-label">Options</p>
<ul class="menu-list"> <ul class="menu-list">

View File

@ -1,4 +1,4 @@
import { DateTime, SystemZone } from "luxon"; import { DateTime } from "luxon";
import { useMutation, useQuery, useQueryClient } from "react-query"; import { useMutation, useQuery, useQueryClient } from "react-query";
import { fetchUserInfo, patchUserInfo } from "../../api"; import { fetchUserInfo, patchUserInfo } from "../../api";
import { Modal } from "../Modal"; import { Modal } from "../Modal";
@ -12,8 +12,8 @@ type DisplayProps = {
const TimezoneDisplay = ({ timezone }: DisplayProps) => { const TimezoneDisplay = ({ timezone }: DisplayProps) => {
const now = DateTime.now().setZone(timezone); const now = DateTime.now().setZone(timezone);
const hour = now.hour; const hour = now.hour.toString().padStart(2, "0");
const minute = now.minute; const minute = now.minute.toString().padStart(2, "0");
return ( return (
<> <>
@ -117,7 +117,7 @@ const TimezoneModal = ({ setModalOpen }) => {
</span> </span>
</button> </button>
<button <button
class="button is-warning" class="button is-success is-outlined"
id="update-bot-timezone" id="update-bot-timezone"
style={{ style={{
margin: "2px", margin: "2px",

View File

@ -10,6 +10,10 @@ export const Welcome = () => (
</span>{" "} </span>{" "}
to get started to get started
</p> </p>
<br></br>
<p>
<strong>Please report bugs!</strong> I can't fix issues if I am unaware of them.
</p>
</div> </div>
</section> </section>
); );