import { cn } from "@rallly/ui";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@rallly/ui/dialog";
import { Label } from "@rallly/ui/label";
import dayjs from "dayjs";
import { GlobeIcon } from "lucide-react";
import React from "react";
import { useInterval } from "react-use";
import spacetime from "spacetime";
import soft from "timezone-soft";
import { TimeFormatPicker } from "@/components/time-format-picker";
import { TimeZoneSelect } from "@/components/time-zone-picker/time-zone-select";
import { Trans } from "@/components/trans";
import { usePreferences } from "@/contexts/preferences";
import { useDayjs } from "@/utils/dayjs";
export const TimePreferences = () => {
const { updatePreferences } = usePreferences();
const { timeFormat, timeZone } = useDayjs();
return (
{
updatePreferences({ timeZone: newTimeZone });
}}
/>
{
updatePreferences({ timeFormat: newTimeFormat });
}}
/>
);
};
export const Clock = ({ className }: { className?: string }) => {
const { timeZone, timeFormat } = useDayjs();
const timeZoneDisplayFormat = soft(timeZone)[0];
const now = spacetime.now(timeZone);
const standardAbbrev = timeZoneDisplayFormat.standard.abbr;
const dstAbbrev = timeZoneDisplayFormat.daylight?.abbr;
const abbrev = now.isDST() ? dstAbbrev : standardAbbrev;
const [time, setTime] = React.useState(new Date());
useInterval(() => {
setTime(new Date());
}, 1000);
return (
{`${dayjs(time).tz(timeZone).format("LT")} ${abbrev}`}
);
};
export const TimesShownIn = () => {
const { timeZone } = useDayjs();
return (
);
};
export const ClockPreferences = ({ children }: React.PropsWithChildren) => {
return (
);
};