Exemplo n.º 1
0
        //TODO this doesn't seem to update right at midnight, it will still retrieve yesterdays info for a while
        //We will need to fetch 7 days and perform a check to ensure we are getting between tomorrow and the 5th day.
        private static WeatherWeek ProcessWeeksWeatherData(WeeksWeatherData daysData)
        {
            WeatherWeek week = new WeatherWeek(DateTime.Now)
            {
                //Store tomorrow's date as 'long date' format: "Thursday, 10 April 2008"
                StartDate = DateTime.Today.AddDays(1),
                EndDate   = DateTime.Today.AddDays(5)
            };

            //Iterate through all weather data retrieved, starting at 1 because it includes today
            //and create WeatherHour objects for each
            for (int i = 1; i < daysData.cnt; i++)
            {
                DateTime date = UnixTimeStampToDateTime(daysData.list[i].dt);
                //If the current result is for today, process it and store it in today
                WeatherWeekDay weather = new WeatherWeekDay()
                {
                    HighTemperature = daysData.list[i].temp.max,
                    LowTemperature  = daysData.list[i].temp.min,
                    Date            = date,
                    IconId          = daysData.list[i].weather[0].icon,
                };
                week.AddDay(weather);
            }
            return(week);
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------
        //-----------------------------End Tomorrow's Weather-----------------------------
        //--------------------------------------------------------------------------------


        //--------------------------------------------------------------------------------
        //---------------------------------Week's Weather---------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherWeek FetchWeeksWeather(Location location)
        {
            WeeksWeatherData forecast = GetWeeksWeatherForecastData(location);
            WeatherWeek      week     = null;

            if (forecast != null)
            {
                week = ProcessWeeksWeatherData(forecast);
            }
            return(week);
        }