UNPKG

2.83 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { InjectionToken } from '@angular/core';
9import { DateAdapter } from '@angular/material/core';
10import { Moment } from 'moment';
11/** Configurable options for {@see MomentDateAdapter}. */
12export interface MatMomentDateAdapterOptions {
13 /**
14 * When enabled, the dates have to match the format exactly.
15 * See https://momentjs.com/guides/#/parsing/strict-mode/.
16 */
17 strict?: boolean;
18 /**
19 * Turns the use of utc dates on or off.
20 * Changing this will change how Angular Material components like DatePicker output dates.
21 * {@default false}
22 */
23 useUtc?: boolean;
24}
25/** InjectionToken for moment date adapter to configure options. */
26export declare const MAT_MOMENT_DATE_ADAPTER_OPTIONS: InjectionToken<MatMomentDateAdapterOptions>;
27/** @docs-private */
28export declare function MAT_MOMENT_DATE_ADAPTER_OPTIONS_FACTORY(): MatMomentDateAdapterOptions;
29/** Adapts Moment.js Dates for use with Angular Material. */
30export declare class MomentDateAdapter extends DateAdapter<Moment> {
31 private _options?;
32 private _localeData;
33 constructor(dateLocale: string, _options?: MatMomentDateAdapterOptions | undefined);
34 setLocale(locale: string): void;
35 getYear(date: Moment): number;
36 getMonth(date: Moment): number;
37 getDate(date: Moment): number;
38 getDayOfWeek(date: Moment): number;
39 getMonthNames(style: 'long' | 'short' | 'narrow'): string[];
40 getDateNames(): string[];
41 getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[];
42 getYearName(date: Moment): string;
43 getFirstDayOfWeek(): number;
44 getNumDaysInMonth(date: Moment): number;
45 clone(date: Moment): Moment;
46 createDate(year: number, month: number, date: number): Moment;
47 today(): Moment;
48 parse(value: any, parseFormat: string | string[]): Moment | null;
49 format(date: Moment, displayFormat: string): string;
50 addCalendarYears(date: Moment, years: number): Moment;
51 addCalendarMonths(date: Moment, months: number): Moment;
52 addCalendarDays(date: Moment, days: number): Moment;
53 toIso8601(date: Moment): string;
54 /**
55 * Returns the given value if given a valid Moment or null. Deserializes valid ISO 8601 strings
56 * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
57 * string into null. Returns an invalid date for all other values.
58 */
59 deserialize(value: any): Moment | null;
60 isDateInstance(obj: any): boolean;
61 isValid(date: Moment): boolean;
62 invalid(): Moment;
63 /** Creates a Moment instance while respecting the current UTC settings. */
64 private _createMoment;
65}
66
\No newline at end of file