UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

53 lines (52 loc) 2.27 kB
import type { ChronosStatics } from './types'; /** * * Use `chronos` with all static methods from the `Chronos` class. * * @description * It serves as both a constructor for creating `Chronos` instances and a namespace for accessing all static methods from the `Chronos` class. * * **Note**: *If a date is provided **without a time component**, the instance will default to `00:00:00.000` UTC and convert it to the **equivalent local time** using the current environment's UTC offset.* * * @example * // Example usage as constructor: * const instance = chronos("2023-12-31"); * const instanceWithTime = chronos(2023, 12, 31, 15, 30, 0); * * @example * // Example usage of static methods: * // Both work identically - thanks to automatic Proxy delegation * chronos.parse("2023-12-31", "YYYY-MM-DD"); * Chronos.parse("2023-12-31", "YYYY-MM-DD"); * * chronos.today(); * chronos.isLeapYear(2024); * chronos.min(date1, date2, date3); * * @remarks *No need to call `chronos` for accessing the static methods. Simply call the static methods.* * * **Available Static Methods:** * * ```ts * chronos.now(): number; * chronos.tomorrow(): Chronos; * chronos.yesterday(): Chronos; * chronos.today(options?: FormatOptions): string; * chronos.with(options: ChronosWithOptions): Chronos; * chronos.parse(dateStr: string, format: string): Chronos; * chronos.utc(dateLike: ChronosInput): Chronos; * chronos.min(...dates: ChronosInput[]): Chronos; * chronos.max(...dates: ChronosInput[]): Chronos; * chronos.isLeapYear(date: ChronosInput): boolean; * chronos.isValidDate(value: unknown): boolean; * chronos.isDateString(value: unknown): boolean; * chronos.isValidChronos(value: unknown): boolean; * chronos.isReconstructable(value: unknown): value is ChronosProperties; * chronos.reconstruct(value: ChronosProperties): Chronos; * chronos.formatTimePart(time: string, format?: TimeParts): string; * chronos.getDatesForDay(day: WeekDay, options?: WeekdayOptions): string[]; * chronos.use(plugin: ChronosPlugin): void; * chronos.register(plugin: ChronosPlugin): void; * ``` */ export declare const chronos: ChronosStatics; export { chronos as chronosjs, chronos as chronosts, chronos as chronus, chronos as chronusjs, chronos as chronusts, };