/** * Formats a timestamp as YYYY-MM-DD. * * @param {number} [timestamp=now()] Default is `now()` * @returns {string} * @url https://pota.quack.uy/use/time/date */ export function date(timestamp?: number): string; /** * Formats a timestamp as YYYY-MM-DD HH:MM. * * @param {number} [timestamp=now()] Default is `now()` * @returns {string} * @url https://pota.quack.uy/use/time/datetime */ export function datetime(timestamp?: number): string; /** * Formats a timestamp as HH:MM. * * @param {number} [timestamp=now()] Default is `now()` * @returns {string} * @url https://pota.quack.uy/use/time */ export function time(timestamp?: number): string; /** * Formats a timestamp as HH:MM:SS. * * @param {number} [timestamp=now()] Default is `now()` * @returns {string} * @url https://pota.quack.uy/use/time/timeWithSeconds */ export function timeWithSeconds(timestamp?: number): string; /** * Formats a timestamp using locale-aware weekday and date components. * * @param {number} [timestamp=now()] Default is `now()` * @param {Intl.LocalesArgument} [lang='en'] Default is `'en'` * @returns {string} * @url https://pota.quack.uy/use/time/day */ export function day(timestamp?: number, lang?: Intl.LocalesArgument): string; /** * Runs a function while reporting execution time via * console/timeReport. * * @template T * @param {string} name * @param {() => T} cb * @param {(duration: number) => void} [timeReport] * @returns {T} * @url https://pota.quack.uy/use/time/measure */ export function measure(name: string, cb: () => T, timeReport?: (duration: number) => void): T; /** * Measures the execution time of a function. * * @param {() => void} fn * @returns {number} Duration in milliseconds. * @url https://pota.quack.uy/use/time/timing */ export function timing(fn: () => void): number; /** * Creates a `setTimeout` that autodisposes. The `delay` could be * reactive. The timeout is NOT started automatically. * * @template T * @param {(...args: unknown[]) => void} callback - Callback to run * once delay completes * @param {Accessor} delay - Delay number or signal * @param {unknown[]} args - Arguments to pass to the callback * @returns {{ start: Function; stop: Function }} * @url https://pota.quack.uy/use/time/useTimeout */ export function useTimeout(callback: (...args: unknown[]) => void, delay: Accessor, ...args: unknown[]): { start: Function; stop: Function; }; /** * Reactive accessor of seconds elapsed since `timestamp` (Unix * seconds). Re-evaluates on the next unit boundary — once per second * under a minute, once per minute under an hour, once per hour under * a day, etc. — so subscribers re-render only when the displayed * value would change, not every second. Returns `0` when `timestamp` * is falsy, and stops ticking in that case. Auto-cleans on scope * dispose via the underlying `useTimeout`. * * @param {number | (() => number | undefined | null)} timestamp - * Unix seconds. May be a value or an accessor. * @returns {() => number} Elapsed seconds since `timestamp`. * @url https://pota.quack.uy/use/time/useElapsed */ export function useElapsed(timestamp: number | (() => number | undefined | null)): () => number; /** * Reactive stopwatch. Counts elapsed milliseconds while running; * `stop()` pauses (preserving the accumulated total), `start()` * resumes, `reset()` zeros it. The `elapsed` accessor updates on a * fixed interval — default `1000`ms, one tick per second. For finer * resolution either lower `interval` or drive it from * `useAnimationFrame` reading `now()` directly. * * Auto-cleans on scope dispose via the underlying `useTimeout`. * * @param {{ autoStart?: boolean; interval?: number }} [opts] * @returns {{ * elapsed: () => number * running: () => boolean * start: () => any * stop: () => any * reset: () => any * }} * @url https://pota.quack.uy/use/time/useStopwatch */ export function useStopwatch(opts?: { autoStart?: boolean; interval?: number; }): { elapsed: () => number; running: () => boolean; start: () => any; stop: () => any; reset: () => any; }; export function now(): number; //# sourceMappingURL=time.d.ts.map