Skip to content

Commit

Permalink
PR Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland committed Jan 25, 2024
1 parent be803ff commit 1da54b4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/utils/getWeatherStations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export const adjustStationDataset = (dataset: IWeatherStation[]) => {
export const findNearestActiveStations = async(targetLat: number, targetLong: number, fromDate: Date,
toDate: Date) => {
const adjustedStationDataset = adjustStationDataset(weatherStations as IWeatherStation[]);
const fromSecs = fromDate.getTime() / 1000;
const toSecs = toDate.getTime() / 1000;
const fromMSecs = fromDate.getTime() ;
const toMSecs = toDate.getTime();
const nearestStations: IStation[] = [];
console.log(adjustedStationDataset);

const insertStation = (station: IWeatherStation, distance: number) => {
const newStation = {station, distance};
Expand All @@ -58,9 +57,9 @@ export const findNearestActiveStations = async(targetLat: number, targetLong: nu
if (station.maxdate === "present") { // If the station is still active (maxdate === "present") then we can use it
shouldInsert = true;
} else { // If the station is not active, we need to check if it has data in the date range
const stationMinSecs = new Date(station.mindate).getTime() / 1000;
const stationMaxSecs = new Date(station.maxdate).getTime() / 1000;
if (stationMinSecs <= toSecs && stationMaxSecs >= fromSecs) {
const stationMinMSecs = new Date(station.mindate).getTime();
const stationMaxMSecs = new Date(station.maxdate).getTime();
if (stationMinMSecs <= toMSecs && stationMaxMSecs >= fromMSecs) {
shouldInsert = true;
}
}
Expand Down

0 comments on commit 1da54b4

Please sign in to comment.