this timer is stupud im not doing it

This commit is contained in:
rift 2023-12-10 19:44:18 -06:00
parent ddfb2ec900
commit bb68711a48
2 changed files with 3 additions and 61 deletions

View file

@ -1,54 +0,0 @@
import { useState, useEffect } from "preact/hooks";
const CurrentTime = () => {
const [currentTime, setCurrentTime] = useState('');
const [currentMinutes, setCurrentMinutes] = useState('');
const [opacity, setOpacity] = useState(0);
useEffect(() => { // LITERAL 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; // 12 hour format
const minutes = now.getMinutes();
const formattedTime = `${dayOfWeek}, ${hours < 10 ? '0' : ''}${hours}`;
setCurrentTime(formattedTime);
};
const updateCurrentMinutes = () => {
const now = new Date();
const minutes = now.getMinutes();
const formattedMinutes = `${minutes < 10 ? '0' : ''}${minutes}`;
setCurrentMinutes(formattedMinutes);
};
updateCurrentTime();
updateCurrentMinutes();
const timeIntervalId = setInterval(updateCurrentTime, 60000);
const minutesIntervalId = setInterval(updateCurrentMinutes, 1000);
return () => {
clearInterval(timeIntervalId);
clearInterval(minutesIntervalId);
};
}, []);
useEffect(() => {
const intervalId = setInterval(() => {
setOpacity((prevOpacity) => (prevOpacity === 0 ? 1 : 0));
}, 1000);
return () => clearInterval(intervalId);
}, []);
return (
<div class="flex flex-row">
<div>{currentTime}</div>
<div style={{ opacity }}>:</div>
<div>{currentMinutes} PM</div>
</div>
);
};
export default CurrentTime;

View file

@ -2,21 +2,17 @@ import { useLocation } from "preact-iso";
import LinkSvg from "../assets/link.svg"; import LinkSvg from "../assets/link.svg";
import LogoSvg from "../assets/logo.svg"; import LogoSvg from "../assets/logo.svg";
import { useState, useEffect } from "preact/hooks" import { useState, useEffect } from "preact/hooks"
import Clock from "./Clock";
export function Header() { export function Header() {
const { url } = useLocation(); const { url } = useLocation();
return ( return (
<div id="navbar" className="h-16 px-4 bg-navbar-color flex flex-row items-center justify-between"> <div id="navbar" className="h-16 px-4 bg-navbar-color flex flex-row items-center justify-between">
<div className="flex flex-row items-center w-1/3"> <div className="flex flex-row items-center w-1/2">
<img src="/logo.png" className="h-16 w-16"></img> <img src="/logo.png" className="h-16 w-16"></img>
<h1 className="font-roboto text-text-color text-4xl">nebula.</h1> <h1 className="font-roboto text-text-color text-4xl">nebula.</h1>
</div> </div>
<div className="w-1/2">
<div className="w-1/3">
<Clock />
</div>
<div className="w-1/3">
<span className="">Games</span> <span className="">Games</span>
</div> </div>
</div> </div>