Skip to content

Commit

Permalink
docs(common): add new date format example to documentation (#51359)
Browse files Browse the repository at this point in the history
PR Close #51359
  • Loading branch information
luishcastroc authored and pkozlowski-opensource committed Aug 15, 2023
1 parent 77efeb5 commit d8e5316
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/common/src/pipes/date_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d8e5316

Please sign in to comment.