public GenericForecastDay GetGenericForecastDay(InternationalForecastWeatherDay jsonDay)
        {
            // JSON provides information for every 3 hours - we want the weather at noon to represent the daily forecast
            InternationalForecastWeatherTimeframe timeframe = jsonDay.Timeframes[jsonDay.Timeframes.Length / 2];
            DateTime           date = Convert.ToDateTime(jsonDay.Date.Substring(0, 10), CultureInfo.CurrentUICulture);
            GenericForecastDay day  = new GenericForecastDay
            {
                DayOfWeek             = date.ToString("dddd"),
                TemperatureFahrenheit = ((int)((jsonDay.Temp_max_f + jsonDay.Temp_min_f) / 2)) + "°F",
                TemperatureCelsius    = ((int)((jsonDay.Temp_max_c + jsonDay.Temp_min_c) / 2)) + "°C",
                WeatherIcon           = GetIconFromInternationalWeather(timeframe.Wx_code),
                WeatherDescription    = timeframe.Wx_desc
            };

            return(day);
        }
예제 #2
0
        public GenericForecastDay GetGenericForecastDay(InternationalForecastWeatherDay jsonDay)
        {
            // JSON provides information for every 3 hours - we want the weather at noon to represent the daily forecast
            InternationalForecastWeatherTimeframe timeframe = jsonDay.Timeframes[jsonDay.Timeframes.Length / 2];
            DateTime           date = Convert.ToDateTime(jsonDay.Date.Substring(0, 10), CultureInfo.CurrentUICulture);
            GenericForecastDay day  = new GenericForecastDay
            {
                Date               = date.Date,
                TemperatureHigh    = jsonDay.Temp_max_f,
                TemperatureLow     = jsonDay.Temp_min_f,
                WeatherIcon        = GetIconFromInternationalWeather(timeframe.Wx_code),
                WeatherDescription = timeframe.Wx_desc
            };

            return(day);
        }