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);
        }
Пример #3
0
        public GenericForecastDay GetGenericForecastDay(string dayName, string tempF, string icon, string desc)
        {
            GenericForecastDay day = new GenericForecastDay
            {
                DayOfWeek             = dayName,
                TemperatureFahrenheit = tempF + "°F",
                WeatherIcon           = GetIconFromUSWeather(icon),
                WeatherDescription    = desc
            };

            if (int.TryParse(tempF, out var temp))
            {
                day.TemperatureCelsius = WeatherHelper.GetCelsius(temp).ToString() + "°C";
            }

            return(day);
        }