Skip to content

Commit a051589

Browse files
committed
Refactor downloadWindData to use parseObsTimeLocal for timestamp comparison
1 parent 3454be1 commit a051589

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

backend/main.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ async function downloadWindData(stationId: number) {
4444
const latestEntryTimestamp = stationStats.value?.latestEntryTimestamp || 0;
4545

4646
const newTableData = data.tableData.filter(
47-
(entry) => new Date(entry.obsTimeLocal).getTime() > latestEntryTimestamp
47+
(entry) =>
48+
parseObsTimeLocal(entry.obsTimeLocal).getTime() >
49+
latestEntryTimestamp
4850
);
4951

5052
if (newTableData.length) {
@@ -59,7 +61,7 @@ async function downloadWindData(stationId: number) {
5961
transaction.set(["station", data.station.id], {
6062
...data.station,
6163
entries: (stationStats.value?.entries ?? 0) + newTableData.length,
62-
latestEntryTimestamp: new Date(
64+
latestEntryTimestamp: parseObsTimeLocal(
6365
newTableData[0].obsTimeLocal
6466
).getTime(),
6567
});
@@ -78,6 +80,10 @@ async function downloadWindData(stationId: number) {
7880
}
7981
}
8082

83+
function parseObsTimeLocal(obsTimeLocal: string): Date {
84+
return new Date(obsTimeLocal + "+02:00");
85+
}
86+
8187
const router = new Router();
8288

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

0 commit comments

Comments
 (0)