UNPKG

@angular/material

Version:
59 lines (58 loc) 2.61 kB
import { DateAdapter } from './date-adapter'; /** Adapts the native JS Date for use with cdk-based components that work with dates. */ export declare class NativeDateAdapter extends DateAdapter<Date> { /** Whether to clamp the date between 1 and 9999 to avoid IE and Edge errors. */ private readonly _clampDate; /** * Whether to use `timeZone: 'utc'` with `Intl.DateTimeFormat` when formatting dates. * Without this `Intl.DateTimeFormat` sometimes chooses the wrong timeZone, which can throw off * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()` * will produce `'8/13/1800'`. */ useUtcForDisplay: boolean; constructor(matDateLocale: string); getYear(date: Date): number; getMonth(date: Date): number; getDate(date: Date): number; getDayOfWeek(date: Date): number; getMonthNames(style: 'long' | 'short' | 'narrow'): string[]; getDateNames(): string[]; getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[]; getYearName(date: Date): string; getFirstDayOfWeek(): number; getNumDaysInMonth(date: Date): number; clone(date: Date): Date; createDate(year: number, month: number, date: number): Date; today(): Date; parse(value: any): Date | null; format(date: Date, displayFormat: Object): string; addCalendarYears(date: Date, years: number): Date; addCalendarMonths(date: Date, months: number): Date; addCalendarDays(date: Date, days: number): Date; toIso8601(date: Date): string; /** * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an * invalid date for all other values. */ deserialize(value: any): Date | null; isDateInstance(obj: any): boolean; isValid(date: Date): boolean; invalid(): Date; /** Creates a date but allows the month and date to overflow. */ private _createDateWithOverflow(year, month, date); /** * Pads a number to make it two digits. * @param n The number to pad. * @returns The padded number. */ private _2digit(n); /** * Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while * other browsers do not. We remove them to make output consistent and because they interfere with * date parsing. * @param str The string to strip direction characters from. * @returns The stripped string. */ private _stripDirectionalityCharacters(str); }