Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/ChatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ChatSidebar from "./ChatSidebar";
import MobileHeader from "./MobileHeader";
import { useChatStore } from "../stores/chatStore";
import { useChatMigration } from "../hooks/useChatMigration";
import Clock from "./Clock";

export default function ChatInterface() {
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -146,6 +147,9 @@ export default function ChatInterface() {
<div className="flex-1">
<h1 className="text-xl font-semibold text-gray-900">{activeThread?.title}</h1>
</div>
<div className="flex justify-end">
<Clock />
</div>
</div>
</div>

Expand Down
123 changes: 123 additions & 0 deletions src/components/Clock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { Clock as ClockIcon } from "lucide-react";

function Clock() {
let now: any = new Date();
let time: any =
now.getHours().toString().padStart(2, "0") +
":" +
now.getMinutes().toString().padStart(2, "0") +
":" +
now.getSeconds().toString().padStart(2, "0");

let polishMonths: any = [
"stycznia",
"lutego",
"marca",
"kwietnia",
"maja",
"czerwca",
"lipca",
"sierpnia",
"września",
"października",
"listopada",
"grudnia",
];
let polishDays: any = ["niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"];

let dateStr: any =
polishDays[now.getDay()] + ", " + now.getDate() + " " + polishMonths[now.getMonth()] + " " + now.getFullYear();

let timeElement: any;
let dateElement: any;

setTimeout(() => {
if (timeElement) {
let newNow: any = new Date();
timeElement.innerHTML =
newNow.getHours().toString().padStart(2, "0") +
":" +
newNow.getMinutes().toString().padStart(2, "0") +
":" +
newNow.getSeconds().toString().padStart(2, "0");
}
if (dateElement) {
let newNow: any = new Date();
dateElement.innerHTML =
polishDays[newNow.getDay()] +
", " +
newNow.getDate() +
" " +
polishMonths[newNow.getMonth()] +
" " +
newNow.getFullYear();
}
}, 1000);

setInterval(() => {
if (timeElement) {
let newNow: any = new Date();
timeElement.innerHTML =
newNow.getHours().toString().padStart(2, "0") +
":" +
newNow.getMinutes().toString().padStart(2, "0") +
":" +
newNow.getSeconds().toString().padStart(2, "0");
}
if (dateElement) {
let newNow: any = new Date();
dateElement.innerHTML =
polishDays[newNow.getDay()] +
", " +
newNow.getDate() +
" " +
polishMonths[newNow.getMonth()] +
" " +
newNow.getFullYear();
}
}, 1000);

return (
<div
style={{
color: "black",
fontSize: "18px",
fontWeight: "bold",
minWidth: "70px",
textAlign: "center",
fontFamily: "monospace",
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: "4px",
}}>
<div
style={{
display: "flex",
alignItems: "center",
gap: "8px",
}}>
<ClockIcon size={18} />
<span
ref={(el: any) => {
timeElement = el;
}}>
{time}
</span>
</div>
<div
ref={(el: any) => {
dateElement = el;
}}
style={{
fontSize: "12px",
color: "#666",
fontWeight: "normal",
}}>
{dateStr}
</div>
</div>
);
}

export default Clock;
Loading