source: trip-planner-front/node_modules/@angular/material/core/datetime/date-adapter.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 9.4 KB
Line 
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 { Observable, Subject } from 'rxjs';
10/** InjectionToken for datepicker that can be used to override default locale code. */
11export declare const MAT_DATE_LOCALE: InjectionToken<string>;
12/** @docs-private */
13export declare function MAT_DATE_LOCALE_FACTORY(): string;
14/** Adapts type `D` to be usable as a date by cdk-based components that work with dates. */
15export declare abstract class DateAdapter<D> {
16 /** The locale to use for all dates. */
17 protected locale: any;
18 protected readonly _localeChanges: Subject<void>;
19 /** A stream that emits when the locale changes. */
20 readonly localeChanges: Observable<void>;
21 /**
22 * Gets the year component of the given date.
23 * @param date The date to extract the year from.
24 * @returns The year component.
25 */
26 abstract getYear(date: D): number;
27 /**
28 * Gets the month component of the given date.
29 * @param date The date to extract the month from.
30 * @returns The month component (0-indexed, 0 = January).
31 */
32 abstract getMonth(date: D): number;
33 /**
34 * Gets the date of the month component of the given date.
35 * @param date The date to extract the date of the month from.
36 * @returns The month component (1-indexed, 1 = first of month).
37 */
38 abstract getDate(date: D): number;
39 /**
40 * Gets the day of the week component of the given date.
41 * @param date The date to extract the day of the week from.
42 * @returns The month component (0-indexed, 0 = Sunday).
43 */
44 abstract getDayOfWeek(date: D): number;
45 /**
46 * Gets a list of names for the months.
47 * @param style The naming style (e.g. long = 'January', short = 'Jan', narrow = 'J').
48 * @returns An ordered list of all month names, starting with January.
49 */
50 abstract getMonthNames(style: 'long' | 'short' | 'narrow'): string[];
51 /**
52 * Gets a list of names for the dates of the month.
53 * @returns An ordered list of all date of the month names, starting with '1'.
54 */
55 abstract getDateNames(): string[];
56 /**
57 * Gets a list of names for the days of the week.
58 * @param style The naming style (e.g. long = 'Sunday', short = 'Sun', narrow = 'S').
59 * @returns An ordered list of all weekday names, starting with Sunday.
60 */
61 abstract getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[];
62 /**
63 * Gets the name for the year of the given date.
64 * @param date The date to get the year name for.
65 * @returns The name of the given year (e.g. '2017').
66 */
67 abstract getYearName(date: D): string;
68 /**
69 * Gets the first day of the week.
70 * @returns The first day of the week (0-indexed, 0 = Sunday).
71 */
72 abstract getFirstDayOfWeek(): number;
73 /**
74 * Gets the number of days in the month of the given date.
75 * @param date The date whose month should be checked.
76 * @returns The number of days in the month of the given date.
77 */
78 abstract getNumDaysInMonth(date: D): number;
79 /**
80 * Clones the given date.
81 * @param date The date to clone
82 * @returns A new date equal to the given date.
83 */
84 abstract clone(date: D): D;
85 /**
86 * Creates a date with the given year, month, and date. Does not allow over/under-flow of the
87 * month and date.
88 * @param year The full year of the date. (e.g. 89 means the year 89, not the year 1989).
89 * @param month The month of the date (0-indexed, 0 = January). Must be an integer 0 - 11.
90 * @param date The date of month of the date. Must be an integer 1 - length of the given month.
91 * @returns The new date, or null if invalid.
92 */
93 abstract createDate(year: number, month: number, date: number): D;
94 /**
95 * Gets today's date.
96 * @returns Today's date.
97 */
98 abstract today(): D;
99 /**
100 * Parses a date from a user-provided value.
101 * @param value The value to parse.
102 * @param parseFormat The expected format of the value being parsed
103 * (type is implementation-dependent).
104 * @returns The parsed date.
105 */
106 abstract parse(value: any, parseFormat: any): D | null;
107 /**
108 * Formats a date as a string according to the given format.
109 * @param date The value to format.
110 * @param displayFormat The format to use to display the date as a string.
111 * @returns The formatted date string.
112 */
113 abstract format(date: D, displayFormat: any): string;
114 /**
115 * Adds the given number of years to the date. Years are counted as if flipping 12 pages on the
116 * calendar for each year and then finding the closest date in the new month. For example when
117 * adding 1 year to Feb 29, 2016, the resulting date will be Feb 28, 2017.
118 * @param date The date to add years to.
119 * @param years The number of years to add (may be negative).
120 * @returns A new date equal to the given one with the specified number of years added.
121 */
122 abstract addCalendarYears(date: D, years: number): D;
123 /**
124 * Adds the given number of months to the date. Months are counted as if flipping a page on the
125 * calendar for each month and then finding the closest date in the new month. For example when
126 * adding 1 month to Jan 31, 2017, the resulting date will be Feb 28, 2017.
127 * @param date The date to add months to.
128 * @param months The number of months to add (may be negative).
129 * @returns A new date equal to the given one with the specified number of months added.
130 */
131 abstract addCalendarMonths(date: D, months: number): D;
132 /**
133 * Adds the given number of days to the date. Days are counted as if moving one cell on the
134 * calendar for each day.
135 * @param date The date to add days to.
136 * @param days The number of days to add (may be negative).
137 * @returns A new date equal to the given one with the specified number of days added.
138 */
139 abstract addCalendarDays(date: D, days: number): D;
140 /**
141 * Gets the RFC 3339 compatible string (https://tools.ietf.org/html/rfc3339) for the given date.
142 * This method is used to generate date strings that are compatible with native HTML attributes
143 * such as the `min` or `max` attribute of an `<input>`.
144 * @param date The date to get the ISO date string for.
145 * @returns The ISO date string date string.
146 */
147 abstract toIso8601(date: D): string;
148 /**
149 * Checks whether the given object is considered a date instance by this DateAdapter.
150 * @param obj The object to check
151 * @returns Whether the object is a date instance.
152 */
153 abstract isDateInstance(obj: any): boolean;
154 /**
155 * Checks whether the given date is valid.
156 * @param date The date to check.
157 * @returns Whether the date is valid.
158 */
159 abstract isValid(date: D): boolean;
160 /**
161 * Gets date instance that is not valid.
162 * @returns An invalid date.
163 */
164 abstract invalid(): D;
165 /**
166 * Given a potential date object, returns that same date object if it is
167 * a valid date, or `null` if it's not a valid date.
168 * @param obj The object to check.
169 * @returns A date or `null`.
170 */
171 getValidDateOrNull(obj: unknown): D | null;
172 /**
173 * Attempts to deserialize a value to a valid date object. This is different from parsing in that
174 * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
175 * string). The default implementation does not allow any deserialization, it simply checks that
176 * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
177 * method on all of its `@Input()` properties that accept dates. It is therefore possible to
178 * support passing values from your backend directly to these properties by overriding this method
179 * to also deserialize the format used by your backend.
180 * @param value The value to be deserialized into a date object.
181 * @returns The deserialized date object, either a valid date, null if the value can be
182 * deserialized into a null date (e.g. the empty string), or an invalid date.
183 */
184 deserialize(value: any): D | null;
185 /**
186 * Sets the locale used for all dates.
187 * @param locale The new locale.
188 */
189 setLocale(locale: any): void;
190 /**
191 * Compares two dates.
192 * @param first The first date to compare.
193 * @param second The second date to compare.
194 * @returns 0 if the dates are equal, a number less than 0 if the first date is earlier,
195 * a number greater than 0 if the first date is later.
196 */
197 compareDate(first: D, second: D): number;
198 /**
199 * Checks if two dates are equal.
200 * @param first The first date to check.
201 * @param second The second date to check.
202 * @returns Whether the two dates are equal.
203 * Null dates are considered equal to other null dates.
204 */
205 sameDate(first: D | null, second: D | null): boolean;
206 /**
207 * Clamp the given date between min and max dates.
208 * @param date The date to clamp.
209 * @param min The minimum value to allow. If null or omitted no min is enforced.
210 * @param max The maximum value to allow. If null or omitted no max is enforced.
211 * @returns `min` if `date` is less than `min`, `max` if date is greater than `max`,
212 * otherwise `date`.
213 */
214 clampDate(date: D, min?: D | null, max?: D | null): D;
215}
Note: See TracBrowser for help on using the repository browser.