/** * Level of precision required when comparing two dates * Day: yyyy-mm-dd * Month: yyyy-mm * Year: yyyy */ export declare enum DatePrecision { DAY = "day", MONTH = "month", YEAR = "year" } export declare enum DateComparison { IS_BEFORE = -1, IS_EQUAL = 0, IS_AFTER = 1 } export declare const DATE_FORMAT_REGEX: RegExp; export default class ModulDate { private innerDate; /** * A DateUtil can be constructed different ways * new DateUtil() - defaults to today's date * new DateUtil('') - defaults to today's date * new DateUtil() - from a javascript date object * new DateUtil() - from a DateUtil date object * new DateUtil(year, month, day) - Year and day represent their respective values, month is the index of the month (0: January, ..., 11: December) * new DateUtil() - any format that matches: * [{1, 4} digits] [separator] [{1, 2} digits] [separator] [{1, 4} digits] [separator]. * At least one of the {1, 4} blocks must have 4 digits * * @param value (optionnal) string | Date (JS date) | DateUtil (this class) * @param year (optionnal) Year in format 2 or 4 digits * @param month (optionnal) Month index (0: January, ..., 11: December) * @param day (optionnal) Day of the month */ constructor(value?: any); constructor(year: number, month: number, day: number); /** * Check if the current date is before or equal to the received date. * * @param otherDate date to be compared with * @param precision level of precision for comparison @see DatePrecision */ isSameOrBefore(otherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date is strictly before to the received date. * * @param otherDate date to be compared with * @param precision level of precision for comparison @see DatePrecision */ isBefore(otherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date is equal to the received date. * * @param otherDate date to be compared with * @param precision level of precision for comparison @see DatePrecision */ isSame(otherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date is equal or after to the received date. * * @param otherDate date to be compared with * @param precision level of precision for comparison @see DatePrecision */ isSameOrAfter(otherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date or after to the received date. * * @param otherDate date to be compared with * @param precision level of precision for comparison @see DatePrecision */ isAfter(otherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date is equal to one of the bounds or between them. * * @param lowerDate lower bound * @param higherDate higher bound * @param precision level of precision for comparison @see DatePrecision */ isBetween(lowerDate: ModulDate, higherDate: ModulDate, precision?: DatePrecision): boolean; /** * Check if the current date is strictly between bounds them. * * @param lowerDate lower bound * @param higherDate higher bound * @param precision level of precision for comparison @see DatePrecision */ isBetweenStrict(lowerDate: ModulDate, higherDate: ModulDate, precision?: DatePrecision): boolean; /** * Compare the current date with the received date to determine if the current date is before, equal or after the * received date * * @param date date to be compared with * @returns @see DateComparison */ compare(date: ModulDate): number; /** * format date string as YYYY-MM-DD */ toString(): string; /** * format date following the date part of the standard ISO-8601 */ toISOString(): string; /** * format date following the locale representation of a date */ toLocaleDateString(): string; /** * Getter for the year value */ fullYear(): number; /** * Getter for the month value */ month(): number; /** * Getter for the day of the month value */ day(): number; /** * Getter for the day of the week value */ dayOfWeek(): number; /** * Compares if two dates are equals * * @param otherDate date to compare with */ equals(otherDate: any): boolean; /** * Calculates the number of days between the current date and the received date. * * @param other * @return Number of days in absolute format */ deltaInDays(other: ModulDate): number; /** * Add an unit of time to a copy of the current date and return it. * * @param valueToAdd The value to add to the time unit. * @param unitOfTime The kind of time unit to be added. * @return A new Date */ add(valueToAdd: number, unitOfTime?: string): Date; /** * subtract an unit of time to a copy of the current date and return it. * * @param valueToSubtract The value to add to the time unit. * @param unitOfTime The kind of time unit to be added. * @return A new Date */ subtract(valueToSubtract: number, unitOfTime?: string): Date; /** * Return a date representing the end of the day of a given date (23:59:59). * * @return A new Date */ beginOfDay(): Date; /** * Return a date representing the end of the day of a given date (23:59:59). * * @return A new Date */ endOfDay(): Date; toDate(): Date; private dateFromString; private convertStringToDate; private padString; private toTime; } //# sourceMappingURL=modul-date.d.ts.map