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

Add forecast_days query parameter #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion OpenMeteo/OpenMeteoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ private string MergeUrlWithOptions(string url, WeatherForecastOptions? options)

uri.Query += "&timeformat=" + options.Timeformat.ToString();

uri.Query += "&past_days=" + options.Past_Days;
if (string.IsNullOrEmpty(options.Start_date) && string.IsNullOrEmpty(options.End_date))
{
uri.Query += "&past_days=" + options.Past_Days;
uri.Query += "&forecast_days=" + options.Forecast_Days;
}

if (options.Start_date != string.Empty)
uri.Query += "&start_date=" + options.Start_date;
Expand Down
7 changes: 7 additions & 0 deletions OpenMeteo/WeatherForecastOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ public class WeatherForecastOptions

/// <summary>
/// Default is "0". Other options: "1", "2"
/// Maximum: 92.
/// </summary>
/// <value></value>
public int Past_Days { get; set; }

/// <summary>
/// Default is 7 days, even if not included in query.
/// Maximum: 16.
/// </summary>
public int Forecast_Days { get; set; } = 7;

/// <summary>
/// The time interval to get weather data. A day must be specified as an ISO8601 date (e.g. 2022-06-30).
/// (yyyy-mm-dd)
Expand Down