nhb-toolbox
Version:
A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.
77 lines • 4.14 kB
TypeScript
import type { ChronosInput, TimeUnit } from '../types';
type MainChronos = typeof import('../Chronos').Chronos;
declare module '../Chronos' {
interface Chronos {
/**
* @instance Returns the number of full years between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeYear(time?: ChronosInput): number;
/**
* @instance Returns the number of full months between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeMonth(time?: ChronosInput): number;
/**
* @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
* @param date - The date to compare (Date object).
* @param time Optional time to compare with the `Chronos` date/time.
* @returns
* - `-1` if the date is yesterday.
* - `0` if the date is today.
* - `1` if the date is tomorrow.
* - Other positive or negative numbers for other relative days (e.g., `-2` for two days ago, `2` for two days ahead).
*/
getRelativeWeek(time?: ChronosInput): number;
/**
* @instance Returns the number of full hours between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeDay(time?: ChronosInput): number;
/**
* @instance Determines how many full weeks apart the input date is from the `Chronos` instance.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns Difference in weeks; negative if past, positive if future.
*/
getRelativeHour(time?: ChronosInput): number;
/**
* @instance Returns the number of full minutes between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeMinute(time?: ChronosInput): number;
/**
* @instance Returns the number of full seconds between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeSecond(time?: ChronosInput): number;
/**
* @instance Returns the number of milliseconds between the input date and now.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
getRelativeMilliSecond(time?: ChronosInput): number;
/**
* @instance Compares the stored date with now, returning the difference in the specified unit.
*
* @param unit The time unit to compare by. Defaults to 'minute'.
* @param time Optional time to compare with the `Chronos` date/time.
* @returns The difference in number, negative when `Chronos` time is a past time else positive.
*/
compare(unit?: TimeUnit, time?: ChronosInput): number;
/** @instance Checks if the current date is today. */
isToday(): boolean;
/** @instance Checks if the current date is tomorrow. */
isTomorrow(): boolean;
/** @instance Checks if the current date is yesterday. */
isYesterday(): boolean;
}
}
/** * Plugin to inject `relative time` related methods */
export declare const relativeTimePlugin: (ChronosClass: MainChronos) => void;
export {};
//# sourceMappingURL=relativeTimePlugin.d.ts.map