mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
docs(common): add new date format example to documentation (#51359)
PR Close #51359
This commit is contained in:
parent
422d0d5ca3
commit
200a264fab
1 changed files with 20 additions and 8 deletions
|
|
@ -52,8 +52,9 @@ export const DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken<string>('DATE_PIPE_
|
|||
* ]
|
||||
* ```
|
||||
*/
|
||||
export const DATE_PIPE_DEFAULT_OPTIONS =
|
||||
new InjectionToken<DatePipeConfig>('DATE_PIPE_DEFAULT_OPTIONS');
|
||||
export const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken<DatePipeConfig>(
|
||||
'DATE_PIPE_DEFAULT_OPTIONS',
|
||||
);
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
|
|
@ -190,6 +191,7 @@ export const DATE_PIPE_DEFAULT_OPTIONS =
|
|||
* {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
|
||||
* {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
|
||||
* {{ dateObj | date:'mm:ss' }} // output is '43:11'
|
||||
* {{ dateObj | date:"MMM dd, yyyy 'at' hh:mm a" }} // output is 'Jun 15, 2015 at 09:43 PM'
|
||||
* ```
|
||||
*
|
||||
* ### Usage example
|
||||
|
|
@ -245,15 +247,25 @@ export class DatePipe implements PipeTransform {
|
|||
*
|
||||
* @returns A date string in the desired format.
|
||||
*/
|
||||
transform(value: Date|string|number, format?: string, timezone?: string, locale?: string): string
|
||||
|null;
|
||||
transform(
|
||||
value: Date|string|number,
|
||||
format?: string,
|
||||
timezone?: string,
|
||||
locale?: string,
|
||||
): string|null;
|
||||
transform(value: null|undefined, format?: string, timezone?: string, locale?: string): null;
|
||||
transform(
|
||||
value: Date|string|number|null|undefined, format?: string, timezone?: string,
|
||||
locale?: string): string|null;
|
||||
value: Date|string|number|null|undefined,
|
||||
format?: string,
|
||||
timezone?: string,
|
||||
locale?: string,
|
||||
): string|null;
|
||||
transform(
|
||||
value: Date|string|number|null|undefined, format?: string, timezone?: string,
|
||||
locale?: string): string|null {
|
||||
value: Date|string|number|null|undefined,
|
||||
format?: string,
|
||||
timezone?: string,
|
||||
locale?: string,
|
||||
): string|null {
|
||||
if (value == null || value === '' || value !== value) return null;
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue