"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useTime = void 0;
const react_1 = __importDefault(require("react"));
const useTime = ({ interval = 1000, onUpdate }) => {
    const [time, setTime] = react_1.default.useState(new Date());
    react_1.default.useEffect(() => {
        const timer = setInterval(() => {
            const newTime = new Date();
            setTime(newTime);
            onUpdate?.(newTime);
        }, interval);
        return () => clearInterval(timer);
    }, [interval, onUpdate]);
    return time;
};
exports.useTime = useTime;
