office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
72 lines (71 loc) • 4.11 kB
TypeScript
import { DayOfWeek, DateRangeType } from '../dateValues/DateValues';
/**
* Returns a date offset from the given date by the specified number of days.
* @param {Date} date - The origin date
* @param {number} days - The number of days to offset. 'days' can be negative.
* @return {Date} A new Date object offset from the origin date by the given number of days
*/
export declare function addDays(date: Date, days: number): Date;
/**
* Returns a date offset from the given date by the specified number of weeks.
* @param {Date} date - The origin date
* @param {number} weeks - The number of weeks to offset. 'weeks' can be negative.
* @return {Date} A new Date object offset from the origin date by the given number of weeks
*/
export declare function addWeeks(date: Date, weeks: number): Date;
/**
* Returns a date offset from the given date by the specified number of months.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param {Date} date - The origin date
* @param {number} months - The number of months to offset. 'months' can be negative.
* @return {Date} A new Date object offset from the origin date by the given number of months
*/
export declare function addMonths(date: Date, months: number): Date;
/**
* Returns a date offset from the given date by the specified number of years.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param {Date} date - The origin date
* @param {number} years - The number of years to offset. 'years' can be negative.
* @return {Date} A new Date object offset from the origin date by the given number of years
*/
export declare function addYears(date: Date, years: number): Date;
/**
* Returns a date that is a copy of the given date, aside from the month changing to the given month.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param {Date} date - The origin date
* @param {number} month - The 0-based index of the month to set on the date.
* @return {Date} A new Date object with the given month set.
*/
export declare function setMonth(date: Date, month: number): Date;
/**
* Compares two dates, and returns true if the two dates (not accounting for time-of-day) are equal.
* @return {boolean} True if the two dates represent the same date (regardless of time-of-day), false otherwise.
*/
export declare function compareDates(date1: Date, date2: Date): boolean;
/**
* Compare the date parts of two dates
* @param {Date} date1 - The first date to compare
* @param {Date} date2 - The second date to compare
* @returns {Number} A negative value if date1 is earlier than date2, 0 if the dates are equal, or a positive value
* if date1 is later than date2.
*/
export declare function compareDatePart(date1: Date, date2: Date): Number;
/**
* Gets the date range array including the specified date. The date range array is calculated as the list
* of dates accounting for the specified first day of the week and date range type.
* @param {Date} date - The input date
* @param {DateRangeType} dateRangeType - The desired date range type, i.e., day, week, month, etc.
* @param {DayOfWeek} dayOfWeek - The first day of the week.
* @returns {Date[]} An array of dates representing the date range containing the specified date.
*/
export declare function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firstDayOfWeek: DayOfWeek): Date[];
/**
* Checks whether the specified date is in the given date range.
* @param {Date} date - The origin date
* @param {Date[]} dateRange - An array of dates to do the lookup on
* @returns {bool} True if the date matches one of the dates in the specified array, false otherwise.
*/
export declare function isInDateRangeArray(date: Date, dateRange: Date[]): boolean;