UNPKG

@tempots/ui

Version:

Provides a higher level of renderables to help fast development with Tempo.

69 lines (68 loc) 3.57 kB
import { Value, Signal } from '@tempots/dom'; /** * Creates a signal that automatically updates with the current time at a specified frequency. * The signal will clean up its interval when disposed. * * @param frequency - Milliseconds between updates (defaults to 1000ms/1 second) * @returns A Value<Date> that updates with the current time at the specified frequency * @public */ export declare const nowSignal: (frequency?: number) => Signal<Date>; /** * Converts a time difference in milliseconds to a human-readable relative time string. * * @param diffInMillis - The time difference in milliseconds. Negative values indicate past times, * positive values indicate future times. * @returns A human-readable string representing the relative time difference: * - For very recent times (< 1 minute): "just now" or "in a moment" * - For other times: formatted strings like "2 minutes ago", "in 3 hours", "yesterday", etc. * @throws {Error} Should never throw due to the Infinity max value in units array * @public */ export declare const timeDiffToString: (diffInMillis: number) => string; /** * Creates a signal that computes the time difference in milliseconds between a target date and a reference date. * * @param date - The target date to compare * @param options - Configuration options * @param options.now - Optional reference date signal (defaults to current time) * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds) * @returns A signal containing the time difference in milliseconds. Negative values indicate past times, * positive values indicate future times. The signal will clean up its resources when disposed. * @public */ export declare const relativeTimeMillisSignal: (date: Value<Date>, { now, frequency }?: { now?: Value<Date>; frequency?: number; }) => import('@tempots/dom').Computed<number>; /** * Creates a signal that computes a human-readable relative time string between a target date and a reference date. * * @param date - The target date to compare * @param options - Configuration options * @param options.now - Optional reference date signal (defaults to current time) * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds) * @returns A signal containing a human-readable relative time string (e.g., "2 minutes ago", "in 3 hours"). * The signal will clean up its resources when disposed. * @public */ export declare const relativeTimeSignal: (date: Value<Date>, options?: { now?: Value<Date>; frequency?: number; }) => import('@tempots/dom').Computed<string>; /** * Creates a signal that computes a human-readable relative time string between a target date and a reference date. * * @param date - The target date to compare * @param options - Configuration options * @param options.now - Optional reference date signal (defaults to current time) * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds) * @returns A signal containing a human-readable relative time string (e.g., "2 minutes ago", "in 3 hours"). * The signal will clean up its resources when disposed. * @deprecated Use makeRelativeTimeSignal instead * @public */ export declare const relativeTime: (date: Value<Date>, options?: { now?: Value<Date>; frequency?: number; }) => import('@tempots/dom').Computed<string>;