Skip to content

Commit 00a54ca

Browse files
committed
Fix weather being incorrect for current dates
1 parent 30e1b55 commit 00a54ca

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Dialog change log
55

66
## 3.0.0 / ????-??-??
77

8+
* Fixed weather being incorrect for current dates; there's a 5-day delay
9+
in the historical data from OpenMeteo
10+
(@thekid)
811
* Merged PR #76: Include videos in lightbox using a minimalistic player.
912
(@thekid)
1013
* Merged PR #75: If a content is formed of a single video, play in feed

src/main/php/de/thekid/dialog/OpenMeteo.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ public function lookup(string|float $lat, string|float $lon, Date $start, ?Date
3838
'hourly' => ['weather_code', 'apparent_temperature'],
3939
];
4040

41-
return $this->endpoint('archive-api')->resource('archive')->post($params, self::URLENCODED)->match([
41+
// There's a 5-day delay in the historical data; forecasts are provided for 7 days
42+
if ($start->getTime() >= time() - 604800) {
43+
$resource= $this->endpoint('api')->resource('forecast');
44+
} else {
45+
$resource= $this->endpoint('archive-api')->resource('archive');
46+
}
47+
48+
return $resource->post($params, self::URLENCODED)->match([
4249
200 => fn($r) => $r->value(),
4350
400 => fn($r) => throw new IllegalArgumentException($r->content()),
4451
]);

0 commit comments

Comments
 (0)