codetrix
Version:
A lightweight lodash-style utility library
54 lines (53 loc) • 1.57 kB
TypeScript
/**
* Checks if the first date is after the second date.
*
* @param date1 - The first date.
* @param date2 - The second date to compare.
* @returns `true` if `date1` is after `date2`.
*
* @example
* isAfter(new Date('2025-01-02'), new Date('2025-01-01')); // true
*/
export declare function isAfter(date1: Date, date2: Date): boolean;
/**
* Checks if the first date is before the second date.
*
* @param date1 - The first date.
* @param date2 - The second date to compare.
* @returns `true` if `date1` is before `date2`.
*
* @example
* isBefore(new Date('2025-01-01'), new Date('2025-01-02')); // true
*/
export declare function isBefore(date1: Date, date2: Date): boolean;
/**
* Checks if two dates fall on the same calendar day (ignores time).
*
* @param date1 - The first date.
* @param date2 - The second date.
* @returns `true` if both dates fall on the same day.
*
* @example
* isSameDay(new Date('2025-01-01'), new Date('2025-01-01T23:59:59')); // true
*/
export declare function isSameDay(date1: Date, date2: Date): boolean;
/**
* Checks if the given date is on a weekend.
*
* @param date - The date to check.
* @returns `true` if the date is Saturday or Sunday.
*
* @example
* isWeekend(new Date('2025-07-20')); // true (Sunday)
*/
export declare function isWeekend(date: Date): boolean;
/**
* Checks if a given year is a leap year.
*
* @param year - The year to check.
* @returns `true` if the year is a leap year.
*
* @example
* isLeapYear(2024); // true
*/
export declare function isLeapYear(year: number): boolean;