fix some linting things

This commit is contained in:
2024-11-29 19:34:14 -06:00
parent 75ed9eb1c7
commit 748bc49780
3 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export class AppComponent {
if (currentTimezone) { if (currentTimezone) {
this.timezones = this.timezoneService.getTimezones(); this.timezones = this.timezoneService.getTimezones();
var second = interval(1000).pipe(startWith(0)); const second = interval(1000).pipe(startWith(0));
second.subscribe(() => { second.subscribe(() => {
this.fiveOclocks = []; this.fiveOclocks = [];
+9 -9
View File
@@ -26,24 +26,24 @@ export function TimezoneCompare(a: Timezone, b: Timezone) {
// http://www.movable-type.co.uk/scripts/latlong.html // http://www.movable-type.co.uk/scripts/latlong.html
export function GetClosestTimezoneFrom(timezone: string, timezones: Timezone[]): Timezone | undefined { export function GetClosestTimezoneFrom(timezone: string, timezones: Timezone[]): Timezone | undefined {
var location1 = timezoneMap[timezone]; const location1 = timezoneMap[timezone];
var closestDist = Number.MAX_SAFE_INTEGER; let closestDist = Number.MAX_SAFE_INTEGER;
var closestTimezone: Timezone | undefined = undefined; let closestTimezone: Timezone | undefined = undefined;
timezones.forEach((timezone) => { timezones.forEach((timezone) => {
var location2 = timezoneMap[timezone.name]; const location2 = timezoneMap[timezone.name];
var deltaLat = (location2.lat - location1.lat) * (Math.PI / 180); const deltaLat = (location2.lat - location1.lat) * (Math.PI / 180);
var deltaLong = (location2.long - location1.long) * (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.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
Math.cos(location1.lat * (Math.PI / 180)) * Math.cos(location1.lat * (Math.PI / 180)) *
Math.cos(location2.lat * (Math.PI / 180)) * Math.cos(location2.lat * (Math.PI / 180)) *
Math.sin(deltaLong / 2) * Math.sin(deltaLong / 2) *
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) { if (dist < closestDist) {
closestDist = dist; closestDist = dist;
@@ -64,7 +64,7 @@ export interface TimezoneLocation {
} }
//TODO: This still needs to be fully populated //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/Abidjan': { lat: 5.359952, long: -4.008256 },
'Africa/Accra': { lat: 5.603717, long: -0.186964 }, 'Africa/Accra': { lat: 5.603717, long: -0.186964 },
'Africa/Addis_Ababa': { lat: 9.03314, long: 38.75008 }, 'Africa/Addis_Ababa': { lat: 9.03314, long: 38.75008 },
@@ -17,16 +17,16 @@ export class TimezoneService {
} }
public getCurrentTimeForTimezone(timezone: string): DateTime | null { public getCurrentTimeForTimezone(timezone: string): DateTime | null {
var dateTime = DateTime.local().setZone(timezone); const dateTime = DateTime.local().setZone(timezone);
return dateTime.isValid ? dateTime : null; return dateTime.isValid ? dateTime : null;
} }
public getCurrentTimeInTimezones(timezones: string[]): Timezone[] { public getCurrentTimeInTimezones(timezones: string[]): Timezone[] {
var dates: Timezone[] = []; const dates: Timezone[] = [];
timezones.forEach((element) => { timezones.forEach((element) => {
var date = this.getCurrentTimeForTimezone(element); const date = this.getCurrentTimeForTimezone(element);
if (date != null) { if (date != null) {
const timezone = { name: element, time: date }; const timezone = { name: element, time: date };
dates.push(timezone); dates.push(timezone);