diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 148fd97..881bce4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -24,7 +24,7 @@ export class AppComponent { if (currentTimezone) { this.timezones = this.timezoneService.getTimezones(); - var second = interval(1000).pipe(startWith(0)); + const second = interval(1000).pipe(startWith(0)); second.subscribe(() => { this.fiveOclocks = []; diff --git a/src/app/timezone/models/timezone.model.ts b/src/app/timezone/models/timezone.model.ts index efec35a..e9ade13 100644 --- a/src/app/timezone/models/timezone.model.ts +++ b/src/app/timezone/models/timezone.model.ts @@ -26,24 +26,24 @@ export function TimezoneCompare(a: Timezone, b: Timezone) { // http://www.movable-type.co.uk/scripts/latlong.html export function GetClosestTimezoneFrom(timezone: string, timezones: Timezone[]): Timezone | undefined { - var location1 = timezoneMap[timezone]; - var closestDist = Number.MAX_SAFE_INTEGER; - var closestTimezone: Timezone | undefined = undefined; + const location1 = timezoneMap[timezone]; + let closestDist = Number.MAX_SAFE_INTEGER; + let closestTimezone: Timezone | undefined = undefined; timezones.forEach((timezone) => { - var location2 = timezoneMap[timezone.name]; + const location2 = timezoneMap[timezone.name]; - var deltaLat = (location2.lat - location1.lat) * (Math.PI / 180); - var deltaLong = (location2.long - location1.long) * (Math.PI / 180); + const deltaLat = (location2.lat - location1.lat) * (Math.PI / 180); + const deltaLong = (location2.long - location1.long) * (Math.PI / 180); - var a = + const a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) + Math.cos(location1.lat * (Math.PI / 180)) * Math.cos(location2.lat * (Math.PI / 180)) * Math.sin(deltaLong / 2) * Math.sin(deltaLong / 2); - var dist = Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + const dist = Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); if (dist < closestDist) { closestDist = dist; @@ -64,7 +64,7 @@ export interface TimezoneLocation { } //TODO: This still needs to be fully populated -export var timezoneMap: { [key: string]: TimezoneLocation } = { +export const timezoneMap: { [key: string]: TimezoneLocation } = { 'Africa/Abidjan': { lat: 5.359952, long: -4.008256 }, 'Africa/Accra': { lat: 5.603717, long: -0.186964 }, 'Africa/Addis_Ababa': { lat: 9.03314, long: 38.75008 }, diff --git a/src/app/timezone/services/timezone.service.ts b/src/app/timezone/services/timezone.service.ts index 58310ec..09b6bc0 100644 --- a/src/app/timezone/services/timezone.service.ts +++ b/src/app/timezone/services/timezone.service.ts @@ -17,16 +17,16 @@ export class TimezoneService { } public getCurrentTimeForTimezone(timezone: string): DateTime | null { - var dateTime = DateTime.local().setZone(timezone); + const dateTime = DateTime.local().setZone(timezone); return dateTime.isValid ? dateTime : null; } public getCurrentTimeInTimezones(timezones: string[]): Timezone[] { - var dates: Timezone[] = []; + const dates: Timezone[] = []; timezones.forEach((element) => { - var date = this.getCurrentTimeForTimezone(element); + const date = this.getCurrentTimeForTimezone(element); if (date != null) { const timezone = { name: element, time: date }; dates.push(timezone);