@mui/x-date-pickers
Version:
The community edition of the MUI X Date and Time Picker components.
143 lines • 6.5 kB
text/typescript
import type { Dayjs } from 'dayjs';
import type { FieldFormatTokenMap, MuiPickersAdapter, AdapterFormats, AdapterOptions, PickersTimezone, DateBuilderReturnType } from "../models/index.mjs";
declare module '@mui/x-date-pickers/models' {
interface PickerValidDateLookup {
dayjs: Dayjs;
}
}
/**
* Based on `@date-io/dayjs`
*
* MIT License
*
* Copyright (c) 2017 Dmitriy Kovalenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
export declare class AdapterDayjs implements MuiPickersAdapter<string> {
isMUIAdapter: boolean;
isTimezoneCompatible: boolean;
lib: string;
locale?: string;
formats: AdapterFormats;
escapedCharacters: {
start: string;
end: string;
};
formatTokenMap: FieldFormatTokenMap;
constructor({
locale,
formats
}?: AdapterOptions<string, never>);
private setLocaleToValue;
private hasUTCPlugin;
private hasTimezonePlugin;
private isSame;
/**
* Replaces "default" by undefined and "system" by the system timezone before passing it to `dayjs`.
*/
private cleanTimezone;
private createSystemDate;
private createUTCDate;
private createTZDate;
private getLocaleFormats;
/**
* `dayjs` does not update the offset when `set` or `add` crosses a DST change (moment does).
* Plain `system` values follow the JS Date DST, and a copied offset breaks later `dayjs` calls.
*/
protected adjustOffset: (value: Dayjs) => Dayjs;
/**
* Before a timezone was standardized, IANA falls back on the Local Mean Time of the location, whose
* offset is not a round number of minutes (`Asia/Kolkata` is `GMT+05:53:28`). `dayjs` mishandles those
* offsets. Only values bound to a timezone with `dayjs.tz` are affected, including `dayjs.tz(value, 'UTC')`.
*/
private isAffectedByLocalMeanTime;
/**
* The number of days in the month of the value, read from its own year and month fields.
* A clone is not reliable: before 1.11.14, `dayjs` can give it other fields (https://github.com/iamkun/dayjs/pull/2505).
*/
private getDaysInMonthFromFields;
/**
* On the dates described by `isAffectedByLocalMeanTime`, `dayjs` moves the day of the month when only
* the year or the month was meant to change.
* `daysInMonth()` is unusable on such a value because it derives from the equally broken
* `endOf('month')`, hence computing it from the fields instead.
* See https://github.com/mui/mui-x/issues/23163
*/
private restoreDayOfMonth;
date: <T extends string | null | undefined>(value?: T, timezone?: PickersTimezone) => DateBuilderReturnType<T>;
getInvalidDate: () => Dayjs;
getTimezone: (value: Dayjs) => string;
setTimezone: (value: Dayjs, timezone: PickersTimezone) => Dayjs;
toJsDate: (value: Dayjs) => Date;
parse: (value: string, format: string) => Dayjs | null;
getCurrentLocaleCode: () => string;
is12HourCycleInCurrentLocale: () => boolean;
expandFormat: (format: string) => string;
isValid: (value: Dayjs | null) => value is Dayjs;
format: (value: Dayjs, formatKey: keyof AdapterFormats) => string;
formatByString: (value: Dayjs, formatString: string) => string;
formatNumber: (numberToFormat: string) => string;
isEqual: (value: Dayjs | null, comparing: Dayjs | null) => boolean;
isSameYear: (value: Dayjs, comparing: Dayjs) => boolean;
isSameMonth: (value: Dayjs, comparing: Dayjs) => boolean;
isSameDay: (value: Dayjs, comparing: Dayjs) => boolean;
isSameHour: (value: Dayjs, comparing: Dayjs) => boolean;
isAfter: (value: Dayjs, comparing: Dayjs) => boolean;
isAfterYear: (value: Dayjs, comparing: Dayjs) => boolean;
isAfterDay: (value: Dayjs, comparing: Dayjs) => boolean;
isBefore: (value: Dayjs, comparing: Dayjs) => boolean;
isBeforeYear: (value: Dayjs, comparing: Dayjs) => boolean;
isBeforeDay: (value: Dayjs, comparing: Dayjs) => boolean;
isWithinRange: (value: Dayjs, [start, end]: [Dayjs, Dayjs]) => boolean;
startOfYear: (value: Dayjs) => Dayjs;
startOfMonth: (value: Dayjs) => Dayjs;
startOfWeek: (value: Dayjs) => Dayjs;
startOfDay: (value: Dayjs) => Dayjs;
endOfYear: (value: Dayjs) => Dayjs;
endOfMonth: (value: Dayjs) => Dayjs;
endOfWeek: (value: Dayjs) => Dayjs;
endOfDay: (value: Dayjs) => Dayjs;
addYears: (value: Dayjs, amount: number) => Dayjs;
addMonths: (value: Dayjs, amount: number) => Dayjs;
addWeeks: (value: Dayjs, amount: number) => Dayjs;
addDays: (value: Dayjs, amount: number) => Dayjs;
addHours: (value: Dayjs, amount: number) => Dayjs;
addMinutes: (value: Dayjs, amount: number) => Dayjs;
addSeconds: (value: Dayjs, amount: number) => Dayjs;
getYear: (value: Dayjs) => number;
getMonth: (value: Dayjs) => number;
getDate: (value: Dayjs) => number;
getHours: (value: Dayjs) => number;
getMinutes: (value: Dayjs) => number;
getSeconds: (value: Dayjs) => number;
getMilliseconds: (value: Dayjs) => number;
setYear: (value: Dayjs, year: number) => Dayjs;
setMonth: (value: Dayjs, month: number) => Dayjs;
setDate: (value: Dayjs, date: number) => Dayjs;
setHours: (value: Dayjs, hours: number) => Dayjs;
setMinutes: (value: Dayjs, minutes: number) => Dayjs;
setSeconds: (value: Dayjs, seconds: number) => Dayjs;
setMilliseconds: (value: Dayjs, milliseconds: number) => Dayjs;
getDaysInMonth: (value: Dayjs) => number;
getWeekArray: (value: Dayjs) => Dayjs[][];
getWeekNumber: (value: Dayjs) => number;
getDayOfWeek(value: Dayjs): number;
getYearRange: ([start, end]: [Dayjs, Dayjs]) => Dayjs[];
}