UNPKG

chronos-ts

Version:

A comprehensive TypeScript package for handling time periods, intervals, and date-related operations.

25 lines (24 loc) 897 B
export declare enum Precision { MINUTE = "minute", HOUR = "hour", DAY = "day", WEEK = "week", MONTH = "month", YEAR = "year" } /** * Converts a given precision to its equivalent duration in milliseconds. * * @param precision - The precision to convert. It can be one of the following: * - `Precision.MINUTE`: 1 minute in milliseconds. * - `Precision.HOUR`: 1 hour in milliseconds. * - `Precision.DAY`: 1 day in milliseconds. * - `Precision.WEEK`: 1 week in milliseconds. * - `Precision.MONTH`: 1 month (approximated as 30 days) in milliseconds. * - `Precision.YEAR`: 1 year (approximated as 365 days) in milliseconds. * * @returns The duration in milliseconds corresponding to the given precision. * * @throws Will throw an error if the provided precision is not supported. */ export declare function getPrecisionInMilliseconds(precision: Precision): number;