Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend weather block to show sunset and sunrise #2028

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
51fabb4
create base for block
Mar 11, 2024
aa9599f
add weather service, todo check that it works
Mar 11, 2024
3c396b3
start adding sunset and sunrise to weather
Mar 15, 2024
a428a5b
add times to format
Mar 15, 2024
6f6af89
datetime conversion
Mar 15, 2024
82a7bcb
sunset as well
Mar 15, 2024
543570c
add keys to config
Mar 15, 2024
e2cec25
add fields for sunrise and sunset to forecastresponse
Mar 18, 2024
af3b657
use sunset and sunrise in response
Mar 18, 2024
22ad18f
remove sun blocks, integrate directly into weather block instead
Mar 18, 2024
7358848
add met.no support for sunset and sunrise
Mar 27, 2024
e59b59e
send sunrise and sunset directly into weatherresult
Mar 27, 2024
1aad21f
clean up
Mar 27, 2024
b54e452
correct url
Mar 27, 2024
57ab6f1
clean up
Mar 27, 2024
9c5a5fd
fix warnings
Mar 27, 2024
39d679c
Merge remote-tracking branch 'local/master' into sunset
Mar 27, 2024
6aeea04
add example
Mar 27, 2024
71cd65d
use library from_timestamp
Apr 5, 2024
88a94c9
fix warning
Apr 5, 2024
13246d5
create function to determine whether to fetch sunset and sunrise info
Apr 6, 2024
651d769
pass toggle for fetching sunset and sunrise downwards
Apr 6, 2024
0d28ea9
make optional
Apr 6, 2024
7681bf8
only get sunset and sunrise if requested
Apr 6, 2024
14781b7
don't unwrap the option just to put it in Some
May 14, 2024
61b5022
replace extend with insert
May 14, 2024
c71a612
surface errors in timestamp conversion
May 15, 2024
b1959a2
remove current_date, use default value provided by met.no instead
Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/blocks/weather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,11 @@ impl WeatherResult {
}

if let Some(sunset) = self.sunset {
values.extend(map! {
"sunset" => Value::datetime(sunset, None),
})
values.insert("sunset".into(), Value::datetime(sunset, None));
}

if let Some(sunrise) = self.sunrise {
values.extend(map! {
"sunrise" => Value::datetime(sunrise, None),
})
values.insert("sunrise".into(), Value::datetime(sunrise, None));
}
values
}
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/weather/open_weather_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ impl WeatherProvider for Service<'_> {
})
};

let sunrise = Some(DateTime::<Utc>::from_timestamp(current_data.sys.sunrise, 0).unwrap());
let sunset = Some(DateTime::<Utc>::from_timestamp(current_data.sys.sunset, 0).unwrap());
let sunrise = DateTime::<Utc>::from_timestamp(current_data.sys.sunrise, 0);
sMailund marked this conversation as resolved.
Show resolved Hide resolved
let sunset = DateTime::<Utc>::from_timestamp(current_data.sys.sunset, 0);

Ok(WeatherResult {
location: current_data.name,
Expand Down