react-calendar
Version:
Ultimate calendar for your React app.
152 lines (151 loc) • 5.57 kB
TypeScript
import type { CalendarType, RangeType } from './types.js';
/**
* Gets day of the week of a given date.
* @param {Date} date Date.
* @param {CalendarType} [calendarType="iso8601"] Calendar type.
* @returns {number} Day of the week.
*/
export declare function getDayOfWeek(date: Date, calendarType?: CalendarType): number;
/**
* Century
*/
/**
* Gets the year of the beginning of a century of a given date.
* @param {Date} date Date.
* @returns {number} Year of the beginning of a century.
*/
export declare function getBeginOfCenturyYear(date: Date): number;
/**
* Decade
*/
/**
* Gets the year of the beginning of a decade of a given date.
* @param {Date} date Date.
* @returns {number} Year of the beginning of a decade.
*/
export declare function getBeginOfDecadeYear(date: Date): number;
/**
* Week
*/
/**
* Returns the beginning of a given week.
*
* @param {Date} date Date.
* @param {CalendarType} [calendarType="iso8601"] Calendar type.
* @returns {Date} Beginning of a given week.
*/
export declare function getBeginOfWeek(date: Date, calendarType?: CalendarType): Date;
/**
* Gets week number according to ISO 8601 or US standard.
* In ISO 8601, Arabic and Hebrew week 1 is the one with January 4.
* In US calendar week 1 is the one with January 1.
*
* @param {Date} date Date.
* @param {CalendarType} [calendarType="iso8601"] Calendar type.
* @returns {number} Week number.
*/
export declare function getWeekNumber(date: Date, calendarType?: CalendarType): number;
/**
* Others
*/
/**
* Returns the beginning of a given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date} Beginning of a given range.
*/
export declare function getBegin(rangeType: RangeType, date: Date): Date;
/**
* Returns the beginning of a previous given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date} Beginning of a previous given range.
*/
export declare function getBeginPrevious(rangeType: RangeType, date: Date): Date;
/**
* Returns the beginning of a next given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date} Beginning of a next given range.
*/
export declare function getBeginNext(rangeType: RangeType, date: Date): Date;
export declare function getBeginPrevious2(rangeType: RangeType, date: Date): Date;
export declare function getBeginNext2(rangeType: RangeType, date: Date): Date;
/**
* Returns the end of a given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date} End of a given range.
*/
export declare function getEnd(rangeType: RangeType, date: Date): Date;
/**
* Returns the end of a previous given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date} End of a previous given range.
*/
export declare function getEndPrevious(rangeType: RangeType, date: Date): Date;
export declare function getEndPrevious2(rangeType: RangeType, date: Date): Date;
/**
* Returns an array with the beginning and the end of a given range.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date Date.
* @returns {Date[]} Beginning and end of a given range.
*/
export declare function getRange(rangeType: RangeType, date: Date): [Date, Date];
/**
* Creates a range out of two values, ensuring they are in order and covering entire period ranges.
*
* @param {RangeType} rangeType Range type (e.g. 'day')
* @param {Date} date1 First date.
* @param {Date} date2 Second date.
* @returns {Date[]} Beginning and end of a given range.
*/
export declare function getValueRange(rangeType: RangeType, date1: Date, date2: Date): [Date, Date];
/**
* @callback FormatYear
* @param {string} locale Locale.
* @param {Date} date Date.
* @returns {string} Formatted year.
*/
/**
* Returns a string labelling a century of a given date.
* For example, for 2017 it will return 2001-2100.
*
* @param {string} locale Locale.
* @param {FormatYear} formatYear Function to format a year.
* @param {Date|string|number} date Date or a year as a string or as a number.
* @returns {string} String labelling a century of a given date.
*/
export declare function getCenturyLabel(locale: string | undefined, formatYear: ((locale: string | undefined, date: Date) => string) | undefined, date: Date): string;
/**
* Returns a string labelling a decade of a given date.
* For example, for 2017 it will return 2011-2020.
*
* @param {string} locale Locale.
* @param {FormatYear} formatYear Function to format a year.
* @param {Date|string|number} date Date or a year as a string or as a number.
* @returns {string} String labelling a decade of a given date.
*/
export declare function getDecadeLabel(locale: string | undefined, formatYear: ((locale: string | undefined, date: Date) => string) | undefined, date: Date): string;
/**
* Returns a boolean determining whether a given date is the current day of the week.
*
* @param {Date} date Date.
* @returns {boolean} Whether a given date is the current day of the week.
*/
export declare function isCurrentDayOfWeek(date: Date): boolean;
/**
* Returns a boolean determining whether a given date is a weekend day.
*
* @param {Date} date Date.
* @param {CalendarType} [calendarType="iso8601"] Calendar type.
* @returns {boolean} Whether a given date is a weekend day.
*/
export declare function isWeekend(date: Date, calendarType?: CalendarType): boolean;