From 71d65f2cda15cdc970222145ee42b07618536747 Mon Sep 17 00:00:00 2001 From: rift <117926989+Riftriot@users.noreply.github.com> Date: Sun, 10 Dec 2023 19:01:34 -0600 Subject: [PATCH] Hell (working) --- src/components/Clock.tsx | 27 +++++++++++++++++++++++++++ src/components/Header.tsx | 6 ++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/components/Clock.tsx diff --git a/src/components/Clock.tsx b/src/components/Clock.tsx new file mode 100644 index 0000000..1f099fc --- /dev/null +++ b/src/components/Clock.tsx @@ -0,0 +1,27 @@ +import { useState, useEffect } from 'preact/hooks'; + +const Clock = () => { + const [currentTime, setCurrentTime] = useState(''); + + useEffect(() => { // Hell + const updateCurrentTime = () => { + const now = new Date(); + const dayOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][now.getDay()]; + let hours = now.getHours(); + hours = hours % 12 || 12; + + const formattedTime = `${dayOfWeek}, ${hours < 10 ? '0' : ''}${hours}`; + + setCurrentTime(formattedTime); + }; + updateCurrentTime(); + const intervalId = setInterval(updateCurrentTime, 1000); + return () => clearInterval(intervalId); + }, []); + + return ( +

{currentTime}

+ ); +}; + +export default Clock; \ No newline at end of file diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 08389f6..957fbd2 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -2,11 +2,9 @@ import { useLocation } from "preact-iso"; import LinkSvg from "../assets/link.svg"; import LogoSvg from "../assets/logo.svg"; import { useState, useEffect } from "preact/hooks" - +import Clock from "./Clock"; export function Header() { const { url } = useLocation(); - const [currentTime, setCurrentTime] = useState(''); - return (
- Clock +
Games