From 200a264fab093e8ca48878c8a95fd882670e8823 Mon Sep 17 00:00:00 2001 From: Luis Castro Date: Mon, 14 Aug 2023 16:27:52 -0400 Subject: [PATCH] docs(common): add new date format example to documentation (#51359) PR Close #51359 --- packages/common/src/pipes/date_pipe.ts | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/common/src/pipes/date_pipe.ts b/packages/common/src/pipes/date_pipe.ts index aef51908543..fed7a4db8c7 100644 --- a/packages/common/src/pipes/date_pipe.ts +++ b/packages/common/src/pipes/date_pipe.ts @@ -52,8 +52,9 @@ export const DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken('DATE_PIPE_ * ] * ``` */ -export const DATE_PIPE_DEFAULT_OPTIONS = - new InjectionToken('DATE_PIPE_DEFAULT_OPTIONS'); +export const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken( + '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 {