UNPKG

2.11 kBTypeScriptView Raw
1import { NgbDateStruct } from './ngb-date-struct';
2import * as i0 from "@angular/core";
3export declare function NGB_DATEPICKER_PARSER_FORMATTER_FACTORY(): NgbDateISOParserFormatter;
4/**
5 * An abstract service for parsing and formatting dates for the
6 * [`NgbInputDatepicker`](#/components/datepicker/api#NgbInputDatepicker) directive.
7 * Converts between the internal `NgbDateStruct` model presentation and a `string` that is displayed in the
8 * input element.
9 *
10 * When user types something in the input this service attempts to parse it into a `NgbDateStruct` object.
11 * And vice versa, when users selects a date in the calendar with the mouse, it must be displayed as a `string`
12 * in the input.
13 *
14 * Default implementation uses the ISO 8601 format, but you can provide another implementation via DI
15 * to use an alternative string format or a custom parsing logic.
16 *
17 * See the [date format overview](#/components/datepicker/overview#date-model) for more details.
18 */
19export declare abstract class NgbDateParserFormatter {
20 /**
21 * Parses the given `string` to an `NgbDateStruct`.
22 *
23 * Implementations should try their best to provide a result, even
24 * partial. They must return `null` if the value can't be parsed.
25 */
26 abstract parse(value: string): NgbDateStruct | null;
27 /**
28 * Formats the given `NgbDateStruct` to a `string`.
29 *
30 * Implementations should return an empty string if the given date is `null`,
31 * and try their best to provide a partial result if the given date is incomplete or invalid.
32 */
33 abstract format(date: NgbDateStruct | null): string;
34 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDateParserFormatter, never>;
35 static ɵprov: i0.ɵɵInjectableDeclaration<NgbDateParserFormatter>;
36}
37export declare class NgbDateISOParserFormatter extends NgbDateParserFormatter {
38 parse(value: string): NgbDateStruct | null;
39 format(date: NgbDateStruct | null): string;
40 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDateISOParserFormatter, never>;
41 static ɵprov: i0.ɵɵInjectableDeclaration<NgbDateISOParserFormatter>;
42}