Add option for single and list of timezones

This commit is contained in:
2021-12-16 22:44:57 -06:00
parent 3cabf260e8
commit 8541588d96
17 changed files with 355 additions and 331 deletions
+1 -25
View File
@@ -1,8 +1,4 @@
import { Component } from '@angular/core';
import { interval, Observable } from 'rxjs';
import { startWith } from 'rxjs/operators';
import { GetClosestTimezoneFrom, Timezone } from './timezone/models/timezone.model';
import { TimezoneService } from './timezone/services/timezone.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@@ -10,25 +6,5 @@ import { TimezoneService } from './timezone/services/timezone.service';
})
export class AppComponent {
dates: any[] = []
fiveOclock: Timezone | undefined;
second: Observable<number>;
fiveOclocks: Timezone[] = [];
constructor(private timezoneService: TimezoneService) {
this.second = interval(1000).pipe(startWith(0)) //every second and give it a starter value
this.second.subscribe(() => {
this.fiveOclocks = [];
this.timezoneService.getCurrentTimeInTimezones(this.timezoneService.getTimezones()).forEach((timezoneObj) => {
if (timezoneObj.time?.hour === 17) {
this.fiveOclocks.push(timezoneObj);
}
this.fiveOclock = GetClosestTimezoneFrom(this.timezoneService.getCurrentTimezone(), this.fiveOclocks)
})
})
}
constructor() { }
}