Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. 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
 */
8
import { PipeTransform } from '@angular/core';
9
/**
10
 * @ngModule CommonModule
11
 * @whatItDoes Formats a date according to locale rules.
12
 * @howToUse `date_expression | date[:format]`
13
 * @description
14
 *
15
 * Where:
16
 * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
17
 * (https://www.w3.org/TR/NOTE-datetime).
18
 * - `format` indicates which date/time components to include. The format can be predefined as
19
 *   shown below or custom as shown in the table.
20
 *   - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
21
 *   - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
22
 *   - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
23
 *   - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
24
 *   - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
25
 *   - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
26
 *   - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
27
 *   - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
28
 *
29
 *
30
 *  | Component | Symbol | Narrow | Short Form   | Long Form         | Numeric   | 2-digit   |
31
 *  |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
32
 *  | era       |   G    | G (A)  | GGG (AD)     | GGGG (Anno Domini)| -         | -         |
33
 *  | year      |   y    | -      | -            | -                 | y (2015)  | yy (15)   |
34
 *  | month     |   M    | L (S)  | MMM (Sep)    | MMMM (September)  | M (9)     | MM (09)   |
35
 *  | day       |   d    | -      | -            | -                 | d (3)     | dd (03)   |
36
 *  | weekday   |   E    | E (S)  | EEE (Sun)    | EEEE (Sunday)     | -         | -         |
37
 *  | hour      |   j    | -      | -            | -                 | j (1 PM)  | jj (1 PM) |
38
 *  | hour12    |   h    | -      | -            | -                 | h (1)     | hh (01)   |
39
 *  | hour24    |   H    | -      | -            | -                 | H (13)    | HH (13)   |
40
 *  | minute    |   m    | -      | -            | -                 | m (5)     | mm (05)   |
41
 *  | second    |   s    | -      | -            | -                 | s (9)     | ss (09)   |
42
 *  | timezone  |   z    | -      | -            | z (Pacific Standard Time)| -  | -         |
43
 *  | timezone  |   Z    | -      | Z (GMT-8:00) | -                 | -         | -         |
44
 *  | timezone  |   a    | -      | a (PM)       | -                 | -         | -         |
45
 *
46
 * In javascript, only the components specified will be respected (not the ordering,
47
 * punctuations, ...) and details of the formatting will be dependent on the locale.
48
 *
49
 * Timezone of the formatted text will be the local system timezone of the end-user's machine.
50
 *
51
 * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
52
 * applied and the formatted text will have the same day, month and year of the expression.
53
 *
54
 * WARNINGS:
55
 * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
56
 *   Instead users should treat the date as an immutable object and change the reference when the
57
 *   pipe needs to re-run (this is to avoid reformatting the date on every change detection run
58
 *   which would be an expensive operation).
59
 * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
60
 *   browsers.
61
 *
62
 * ### Examples
63
 *
64
 * Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
65
 * in the _local_ time and locale is 'en-US':
66
 *
67
 * ```
68
 *     {{ dateObj | date }}               // output is 'Jun 15, 2015'
69
 *     {{ dateObj | date:'medium' }}      // output is 'Jun 15, 2015, 9:43:11 PM'
70
 *     {{ dateObj | date:'shortTime' }}   // output is '9:43 PM'
71
 *     {{ dateObj | date:'mmss' }}        // output is '43:11'
72
 * ```
73
 *
74
 * {@example common/pipes/ts/date_pipe.ts region='DatePipe'}
75
 *
76
 * @stable
77
 */
78
export declare class DatePipe implements PipeTransform {
79
    private _locale;
80
    constructor(_locale: string);
81
    transform(value: any, pattern?: string): string | null;
82
}
(3-3/11)