Skip to content

Commit

Permalink
chore: fix formatDateAgo nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Aug 14, 2023
1 parent acadb0f commit 132b00d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/component-library/ui-elements/ago/ago.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AgoPipe implements PipeTransform {

transform(date?: Date | null): Observable<string> {
return this.interval$.pipe(
map(() => formatDateAgo(date!)),
map(() => formatDateAgo(date)),
distinctUntilChanged(),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/component-library/ui-elements/ago/formatDateAgo.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {formatDistanceToNow} from 'date-fns';
import {DateInput} from "./date-input";
import {DateInput} from './date-input';

/**
* Formats date as "{n} {timeUnit} ago" or "in {n} {timeUnit}s".
* @param date date
*/
export function formatDateAgo(date?: DateInput): string {
export function formatDateAgo(date?: DateInput | null): string {
if (!date) {
return '';
return 'never';
}
if (typeof date === 'string') {
date = new Date(date);
Expand Down

0 comments on commit 132b00d

Please sign in to comment.