Skip to content

Commit

Permalink
Refactor downloadWindData to use parseObsTimeLocal for timestamp comp…
Browse files Browse the repository at this point in the history
…arison
  • Loading branch information
bluescorpian committed Feb 5, 2025
1 parent 3454be1 commit a051589
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ async function downloadWindData(stationId: number) {
const latestEntryTimestamp = stationStats.value?.latestEntryTimestamp || 0;

const newTableData = data.tableData.filter(
(entry) => new Date(entry.obsTimeLocal).getTime() > latestEntryTimestamp
(entry) =>
parseObsTimeLocal(entry.obsTimeLocal).getTime() >
latestEntryTimestamp
);

if (newTableData.length) {
Expand All @@ -59,7 +61,7 @@ async function downloadWindData(stationId: number) {
transaction.set(["station", data.station.id], {
...data.station,
entries: (stationStats.value?.entries ?? 0) + newTableData.length,
latestEntryTimestamp: new Date(
latestEntryTimestamp: parseObsTimeLocal(
newTableData[0].obsTimeLocal
).getTime(),
});
Expand All @@ -78,6 +80,10 @@ async function downloadWindData(stationId: number) {
}
}

function parseObsTimeLocal(obsTimeLocal: string): Date {
return new Date(obsTimeLocal + "+02:00");
}

const router = new Router();

router.post("/login", async (ctx) => {
Expand Down

0 comments on commit a051589

Please sign in to comment.