docs(common): add new date format example to documentation (#51359)

PR Close #51359
This commit is contained in:
Luis Castro 2023-08-14 16:27:52 -04:00 committed by Pawel Kozlowski
parent 422d0d5ca3
commit 200a264fab

View file

@ -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 {