Skip to content

Commit

Permalink
Merge ca397ab into 2851dcf
Browse files Browse the repository at this point in the history
  • Loading branch information
zusorio authored Nov 20, 2024
2 parents 2851dcf + ca397ab commit fc75203
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DateArg } from 'date-fns/types';
export class RelativeTimeComponent {
@Input() date?: DateArg<Date>;
@Input() suffix = true;
@Input() showSeconds = true;

get relativeTime(): string {
if (!this.date) return '';
Expand All @@ -24,6 +25,7 @@ export class RelativeTimeComponent {

get absoluteTime(): string {
if (!this.date) return '';
return format(this.date, 'PPpp');
if (this.showSeconds) return format(this.date, 'PPpp');
return format(this.date, 'PPp');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ng-container matColumnDef="created_at">
<th mat-header-cell *matHeaderCellDef>Creation date</th>
<td mat-cell *matCellDef="let element">
{{ element.created_at | date: "EE, dd MMM y HH:mm:ss" }}
<app-relative-time [date]="element.created_at" />
</td>
</ng-container>

Expand All @@ -62,6 +62,7 @@
[date]="
subMinutes(Date.now(), element.idle_state.idle_for_minutes!)
"
[showSeconds]="false"
/>
}
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
import { userEvent, within } from '@storybook/test';
import MockDate from 'mockdate';
import { of } from 'rxjs';
import {
Session,
Expand All @@ -22,6 +23,9 @@ import { SessionOverviewComponent } from './session-overview.component';
const meta: Meta<SessionOverviewComponent> = {
title: 'Session Components/Session Overview',
component: SessionOverviewComponent,
beforeEach: () => {
MockDate.set(new Date('2024-05-01'));
},
};

export default meta;
Expand Down

0 comments on commit fc75203

Please sign in to comment.