mirror of
https://github.com/BradNut/weddingsite
synced 2025-09-08 17:40:36 +00:00
23 lines
570 B
JavaScript
23 lines
570 B
JavaScript
|
|
import { useState } from 'react';
|
||
|
|
import useInterval from '../utils/useInterval';
|
||
|
|
|
||
|
|
function useWeddingStart({ update = 60000 }) {
|
||
|
|
const weddingDate = 1906736400000;
|
||
|
|
const [timeToWedding, setTime] = useState(weddingDate - Date.now());
|
||
|
|
useInterval(() => {
|
||
|
|
setTime(weddingDate - Date.now());
|
||
|
|
}, update);
|
||
|
|
return {
|
||
|
|
timeToWedding,
|
||
|
|
timeAsDays: Math.ceil(timeToWedding / 1000 / 60 / 60 / 24),
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export default function WeddingStart() {
|
||
|
|
const { timeToWedding, timeAsDays } = useWeddingStart({
|
||
|
|
update: 60000,
|
||
|
|
});
|
||
|
|
|
||
|
|
return <>{timeAsDays}</>;
|
||
|
|
}
|