Last active
February 16, 2020 20:42
-
-
Save ianfnelson/d05b7b5c9e31c7abd165f1ea5dfd9dd9 to your computer and use it in GitHub Desktop.
Colour Blanket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var darkSky = new DarkSky.Services.DarkSkyService("API_KEY_HERE"); | |
var date = new DateTime(2020,1,1); | |
do | |
{ | |
var forecast = darkSky.GetForecast(53.812174, -1.096165, | |
new OptionalParameters{MeasurementUnits ="uk2", ForecastDateTime = date}).Result; | |
var temperatureLow = Math.Round(forecast.Response.Daily.Data[0].TemperatureMin.Value, 0, MidpointRounding.AwayFromZero); | |
var temperatureHigh = Math.Round(forecast.Response.Daily.Data[0].TemperatureMax.Value, 0, | |
MidpointRounding.AwayFromZero); | |
var temperatureAverage = | |
Math.Round(forecast.Response.Hourly.Data.Select(x => x.Temperature.Value).Average(), 0, MidpointRounding.AwayFromZero); | |
Console.WriteLine($"Date: {date.ToShortDateString()}; Min: {temperatureLow,2}; Max: {temperatureHigh,2}; Avg: {temperatureAverage,2}"); | |
date = date.AddDays(1); | |
} while (date<DateTime.Today); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment