reablocks
Version:
Component library for React
61 lines (60 loc) • 2.47 kB
TypeScript
/**
* Get the month names for a given locale and format.
*
* Reference: https://www.abeautifulsite.net/posts/getting-localized-month-and-day-names-in-the-browser/
*/
export declare function getMonthNames(locale?: string, format?: 'long' | 'numeric' | '2-digit' | 'short' | 'narrow'): string[];
export declare const monthNames: string[];
export declare function getDayLabels(locale?: string): string[];
export declare const daysOfWeek: string[];
export interface Day {
date: Date;
dayOfMonth: number;
isWeekendDay: boolean;
isPreviousMonth: boolean;
isNextMonth: boolean;
isToday: boolean;
formattedDate: string;
}
export interface DayOptions {
format: string;
}
export declare function getWeeks(date: Date, options?: DayOptions): Day[][];
/**
* Get attributes for the day:
* - isActive: if the day is within the selected range
* - isRangeStart: if the day is the start of the range
* - isRangeEnd: if the day is the end of the range
*
* "Range" here refers to a selection OR a selected date to hovered date.
*/
export declare function getDayAttributes(day: Date, current: Date | [Date, Date] | [Date, undefined] | [undefined, undefined] | undefined, hover: Date, isRange: boolean): {
isActive: boolean;
isRangeStart: boolean;
isRangeEnd: boolean;
};
/**
* Get whether the space below the current day is empty or not
*/
export declare function isNextWeekEmpty(day: Date, range: [Date, Date], hideNextMonth: boolean): boolean;
/**
* Get whether the space above the current day is empty or not
*/
export declare function isPreviousWeekEmpty(day: Date, range: [Date, Date], hidePrevMonth: boolean): boolean;
/**
* Update the time or date based on the current date and the range start.
*
* @param currentDate - The current date or range.
* @param newDate - The new date to update.
* @param isRange - Whether the current date is a range.
* @param rangeStart - Whether the current date is the start of the range.
* @returns The updated date.
*/
export declare function updateDateTime(currentDate: Date | [Date, Date], newDate: Date, isRange?: boolean, rangeStart?: boolean): Date;
/**
* Check if a preset is active
* @param presetValue - The preset value to check
* @param value - The value to check against
* @returns True if the preset is active, false otherwise
*/
export declare const isPresetActive: (presetValue: Date | [Date, Date], value: Date | [Date, Date], includeTime?: boolean) => boolean;