diff --git a/components/index.tsx b/components/index.tsx
index fcc8ba6..b400adc 100644
--- a/components/index.tsx
+++ b/components/index.tsx
@@ -1,17 +1,17 @@
+'use client';
+
import { useRecoilState } from "recoil";
import Background from "./background";
import Search from "./search/search";
import { bgFocusState } from "./state/background";
+import Time from "./time";
export default function Homepage() {
const [isFocus, setFocus] = useRecoilState(bgFocusState);
return (
- setFocus(false)}
- />
+
+ setFocus(false)} />
{
setFocus(true);
@@ -20,4 +20,4 @@ export default function Homepage() {
/>
);
-}
\ No newline at end of file
+}
diff --git a/components/time.tsx b/components/time.tsx
new file mode 100644
index 0000000..21becc0
--- /dev/null
+++ b/components/time.tsx
@@ -0,0 +1,41 @@
+'use client';
+
+import React, {useState, useEffect} from "react";
+
+export default function Time(props: {
+ showSecond: boolean;
+}){
+ const [currentTime, setCurrentTime] = useState(new Date());
+
+ useEffect(() => {
+ const timer = setInterval(() => {
+ setCurrentTime(new Date());
+ }, 150);
+
+ return () => {
+ clearInterval(timer);
+ };
+ }, []);
+
+ const formatTime = () => {
+ const hours = currentTime.getHours().toString().padStart(2, "0");
+ const minutes = currentTime.getMinutes().toString().padStart(2, "0");
+ const seconds = currentTime.getSeconds().toString().padStart(2, "0");
+
+ if (props.showSecond) {
+ return `${hours}:${minutes}:${seconds}`;
+ } else {
+ return `${hours}:${minutes}`;
+ }
+ };
+
+ return (
+
+ {formatTime()}
+
+ );
+};