angelodlfrtr / open-meteo-rs

Rust API client for https://open-meteo.com/
MIT License
20 stars 4 forks source link

Fix panic when requesting forecast with negative utc offset #2

Closed rparrett closed 1 year ago

rparrett commented 1 year ago

This fixes panics like

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Decode, source: Error("invalid value: integer `-14400`, expected u64", line: 1, column: 105) }', examples/forecast.rs:82:43

When requesting forecast data for a time zone with a negative utc offset.

To reproduce the panic:

diff --git a/examples/forecast.rs b/examples/forecast.rs
index e775554..0d2d75a 100644
--- a/examples/forecast.rs
+++ b/examples/forecast.rs
@@ -43,7 +43,7 @@ async fn main() {
     opts.precipitation_unit = Some("inch".try_into().unwrap()); // or

     // Time zone (default to UTC)
-    opts.time_zone = Some(chrono_tz::Europe::Paris.name().into());
+    opts.time_zone = Some(chrono_tz::America::New_York.name().into());
angelodlfrtr commented 1 year ago

Hi @rparrett, thanks for the PR !