UNPKG

@matheo/datepicker

Version:

Angular material date+time picker

82 lines (81 loc) 4.07 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { InjectionToken } from '@angular/core'; import { DateAdapter } from '@matheo/datepicker/core'; import { DateTime as LuxonDateTime } from 'luxon'; import * as i0 from "@angular/core"; /** Configurable options for {@see LuxonDateAdapter}. */ export interface MatLuxonDateAdapterOptions { /** * Turns the use of utc dates on or off. * Changing this will change how Angular Material components like DatePicker output dates. * {@default false} */ useUtc: boolean; /** * Luxon does not have support for retrieving the first day of the week. * This allows supplying a custom function to override it. * Remember that you need to return 0 = Sunday, 1 = Monday */ firstDayOfWeek?: (locale: string) => number; } /** InjectionToken for LuxonDateAdapter to configure options. */ export declare const MAT_LUXON_DATE_ADAPTER_OPTIONS: InjectionToken<MatLuxonDateAdapterOptions>; /** @docs-private */ export declare function MAT_LUXON_DATE_ADAPTER_OPTIONS_FACTORY(): MatLuxonDateAdapterOptions; /** Adapts Luxon Dates for use with Angular Material. */ export declare class LuxonDateAdapter extends DateAdapter<LuxonDateTime> { private _useUTC; private _getFirstDayOfWeek?; constructor(dateLocale: string, options?: MatLuxonDateAdapterOptions); setLocale(locale: string): void; getYear(date: LuxonDateTime): number; getMonth(date: LuxonDateTime): number; getDate(date: LuxonDateTime): number; getHours(date: LuxonDateTime): number; setHours(date: LuxonDateTime, hour: number): LuxonDateTime; getMinutes(date: LuxonDateTime): number; setMinutes(date: LuxonDateTime, minute: number): LuxonDateTime; getSeconds(date: LuxonDateTime): number; setSeconds(date: LuxonDateTime, second: number, ms?: number): LuxonDateTime; getMilliseconds(date: LuxonDateTime): number; getDayOfWeek(date: LuxonDateTime): number; getMonthNames(style: 'long' | 'short' | 'narrow'): string[]; getDateNames(): string[]; getHourNames(): string[]; getMinuteNames(): string[]; getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[]; getYearName(date: LuxonDateTime): string; getFirstDayOfWeek(): number; getNumDaysInMonth(date: LuxonDateTime): number; clone(date: LuxonDateTime): LuxonDateTime; createDate(year: number, month: number, date: number, hours?: number, minutes?: number, seconds?: number, ms?: number): LuxonDateTime; today(): LuxonDateTime; parse(value: any, parseFormat: string | string[]): LuxonDateTime | null; format(date: LuxonDateTime, displayFormat: string): string; addCalendarYears(date: LuxonDateTime, years: number): LuxonDateTime; addCalendarMonths(date: LuxonDateTime, months: number): LuxonDateTime; addCalendarDays(date: LuxonDateTime, days: number): LuxonDateTime; addCalendarHours(date: LuxonDateTime, hours: number): LuxonDateTime; addCalendarMinutes(date: LuxonDateTime, minutes: number): LuxonDateTime; addCalendarSeconds(date: LuxonDateTime, seconds: number, ms?: number): LuxonDateTime; toIso8601(date: LuxonDateTime): string; /** * Returns the given value if given a valid Luxon or null. Deserializes valid ISO 8601 strings * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid DateTime and empty * string into null. Returns an invalid date for all other values. */ deserialize(value: any): LuxonDateTime | null; isDateInstance(obj: any): boolean; isValid(date: LuxonDateTime): boolean; invalid(): LuxonDateTime; /** Gets the options that should be used when constructing a new `DateTime` object. */ private _getOptions; static ɵfac: i0.ɵɵFactoryDeclaration<LuxonDateAdapter, [{ optional: true; }, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<LuxonDateAdapter>; }