diff --git a/package.json b/package.json
index 941d2e0..b977ab6 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,6 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.309.0",
- "moment": "^2.30.1",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index dd3ff4d..a8939a7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -29,9 +29,6 @@ dependencies:
lucide-react:
specifier: ^0.309.0
version: 0.309.0(react@18.2.0)
- moment:
- specifier: ^2.30.1
- version: 2.30.1
next:
specifier: 14.0.4
version: 14.0.4(react-dom@18.2.0)(react@18.2.0)
@@ -3108,10 +3105,6 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
- /moment@2.30.1:
- resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
- dev: false
-
/ms@2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: true
diff --git a/src/app/components/CountDown.tsx b/src/app/components/CountDown.tsx
index a954df5..e313239 100644
--- a/src/app/components/CountDown.tsx
+++ b/src/app/components/CountDown.tsx
@@ -1,7 +1,6 @@
"use client";
import { conferenceDateTime } from "@/data/timing";
-import moment from "moment";
import Wave from "@/assets/images/home/count-down-wave.svg";
import WaveMobile from "@/assets/images/home/count-down-wave-mobile.svg";
import Image from "next/image";
@@ -24,26 +23,40 @@ export default function CountDown() {
- تا شروع دومین همایش فرانت چپتر + از همایش سال ۱۴۰۲ گذشته
); } const CountDownTimer = () => { + const calculateDuration = (start: number, end: number) => { + const totalSeconds = Math.floor((end - start) / 1000); + const days = Math.floor(totalSeconds / (3600 * 24)); + const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600); + const minutes = Math.floor((totalSeconds % 3600) / 60); + const seconds = Math.floor(totalSeconds % 60); + + return { + days, + hours, + minutes, + seconds, + }; + }; + const [now, setNow] = useState(Date.now()); - const duration = moment.duration( - Math.max(moment(conferenceDateTime).diff(now), 0), - ); + const conferenceDate = conferenceDateTime.getTime(); + const duration = calculateDuration(now, conferenceDate); - /** - * Update the current time every second - */ + // Update the current time every second useEffect(() => { const interval = setInterval(() => { setNow(Date.now()); @@ -54,32 +67,32 @@ const CountDownTimer = () => { const times = [ { label: "ثانیه", - value: duration.seconds(), + value: duration.seconds, }, { label: "دقیقه", - value: duration.minutes(), + value: duration.minutes, }, { label: "ساعت", - value: duration.hours(), + value: duration.hours, }, { label: "روز", - value: Math.trunc(duration.asDays()), + value: duration.days, }, ]; return (