dev-utils-plus
Version:
Type-safe utility functions for JavaScript/TypeScript: string, array, object, date, validation, crypto, format, math
64 lines • 1.7 kB
TypeScript
/**
* Date utility functions for common operations
*/
/**
* Formats a date to a readable string
*/
export declare function formatDate(date: Date, format?: string): string;
/**
* Gets the start of a day (00:00:00)
*/
export declare function startOfDay(date: Date): Date;
/**
* Gets the end of a day (23:59:59.999)
*/
export declare function endOfDay(date: Date): Date;
/**
* Adds days to a date
*/
export declare function addDays(date: Date, days: number): Date;
/**
* Subtracts days from a date
*/
export declare function subtractDays(date: Date, days: number): Date;
/**
* Gets the difference between two dates in days
*/
export declare function daysDifference(date1: Date, date2: Date): number;
/**
* Checks if a date is today
*/
export declare function isToday(date: Date): boolean;
/**
* Checks if a date is in the past
*/
export declare function isPast(date: Date): boolean;
/**
* Checks if a date is in the future
*/
export declare function isFuture(date: Date): boolean;
/**
* Gets the age from a birth date
*/
export declare function getAge(birthDate: Date): number;
/**
* Gets the week number of a date
*/
export declare function getWeekNumber(date: Date): number;
/**
* Checks if a year is a leap year
*/
export declare function isLeapYear(year: number): boolean;
/**
* Gets the number of days in a month
*/
export declare function getDaysInMonth(year: number, month: number): number;
/**
* Parses a date string to a Date object
*/
export declare function parseDate(dateString: string): Date | null;
/**
* Gets a relative time string (e.g., "2 hours ago")
*/
export declare function getRelativeTime(date: Date): string;
//# sourceMappingURL=index.d.ts.map