Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/event-page/event-date-time.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export class EventDateTimePipe implements PipeTransform {
* The event object
*
* @return
* New date/time formatted object
* The date object
*/
transform(event: any): string {
transform(event: any): Date {
let date;

try {
date = new Date(parseFloat(event.properties.time));
} catch (e) {
date = null;
}
return date;

return this.formatter.dateTime(date);
}
}
4 changes: 3 additions & 1 deletion src/app/event-page/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<header>
<ul *ngIf="event?.id">
<li [innerHTML]="event | eventDateTime"></li>
<li><shared-date-info [date]="event | eventDateTime" [local]="false">
</shared-date-info>
</li>
<li [innerHTML]="event | eventLocation"></li>
<li [innerHTML]="event | eventDepth"></li>
</ul>
Expand Down
8 changes: 8 additions & 0 deletions src/app/shared/date-info/date-info.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ng-container *ngIf="date else noDate">
<time [attr.datetime]="date.toISOString()">
{{ date | sharedDateTime:(local ? -date.getTimezoneOffset() : 0) }}
</time>
</ng-container>
<ng-template #noDate>
&ndash;
</ng-template>
Empty file.
25 changes: 25 additions & 0 deletions src/app/shared/date-info/date-info.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DateInfoComponent } from './date-info.component';

describe('DateInfoComponent', () => {
let component: DateInfoComponent;
let fixture: ComponentFixture<DateInfoComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DateInfoComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DateInfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
23 changes: 23 additions & 0 deletions src/app/shared/date-info/date-info.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ChangeDetectionStrategy, Component, Input} from '@angular/core';

/**
* Shared date-info component for use displaying local/UTC dateTime
*
* @param date
* Date object of an event
* @param local
* If time is supposed to be local
*/

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'shared-date-info',
templateUrl: './date-info.component.html',
styleUrls: ['./date-info.component.scss']
})
export class DateInfoComponent{
@Input()
date: Date;
@Input()
local: boolean = false;
}
3 changes: 3 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AttributionComponent } from './attribution/attribution.component';
import { BeachballComponent } from './beachball/beachball.component';
import { BubbleComponent } from './bubble/bubble.component';
import { CoordinatesComponent } from './coordinates/coordinates.component';
import { DateInfoComponent } from './date-info/date-info.component';
import { DateTimePipe } from './date-time.pipe';
import { DegreesPipe } from './degrees.pipe';
import { DirectionPipe } from './direction.pipe';
Expand Down Expand Up @@ -93,6 +94,7 @@ import { OriginSummaryComponent } from '@shared/origin-summary/origin-summary.co
BeachballComponent,
BubbleComponent,
CoordinatesComponent,
DateInfoComponent,
DateTimePipe,
DegreesPipe,
DirectionPipe,
Expand Down Expand Up @@ -173,6 +175,7 @@ import { OriginSummaryComponent } from '@shared/origin-summary/origin-summary.co
BeachballComponent,
BubbleComponent,
CoordinatesComponent,
DateInfoComponent,
DateTimePipe,
DegreesPipe,
DirectionPipe,
Expand Down