private void SetWeatherInfo(WeatherForcast ThisWeather, dynamic WeatherJson) { var WeatherInfo = WeatherJson.list; DateTime LastForcast = DateTime.Now; for (var i = 0; i < WeatherInfo.Count; i++) { WeatherCondition ThisCondition = new WeatherCondition(); try { // Unix timestamp is seconds past epoch Double UnixTimeStamp = WeatherInfo[i].dt; System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); ThisCondition.ConditionDate = dtDateTime.AddSeconds(UnixTimeStamp).ToLocalTime(); ThisCondition.ConditionText = WeatherInfo[i].weather[0].main; ThisCondition.ConditionCode = WeatherInfo[i].weather[0].icon; ThisCondition.Humidity = WeatherInfo[i].humidity; ThisCondition.Visibility = 0; ThisCondition.Pressure = WeatherInfo[i].pressure; ThisCondition.Temperature = WeatherInfo[i].temp.day; ThisCondition.High = WeatherInfo[i].temp.max; ThisCondition.Low = WeatherInfo[i].temp.min; ThisCondition.WindDirection = WeatherInfo[i].deg; ThisCondition.WindSpeed = WeatherInfo[i].speed * 3.6; if (i == 0) { ThisWeather.Today = ThisCondition; } } catch (Exception e) { ThisCondition.ConditionText = e.Message; } ThisWeather.Forecast.Add(ThisCondition); if (i >= 5) { return; } } }
public WeatherForcast() { Today = new WeatherCondition(); Forecast = new List <WeatherCondition>(); }