Esempio n. 1
0
        private static WeatherDay ProcessTodaysWeatherData(DaysWeatherData daysData)
        {
            WeatherDay today = new WeatherDay(DateTime.Now)
            {
                //Store tomorrow's date as 'long date' format: "Thursday, 10 April 2008"
                Date = DateTime.Today.ToString("D")
            };

            //Iterate through all weather data retrieved and create BasicWeather objects
            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
                if (ValidTimeToday(date))
                {
                    BasicWeather weather = new BasicWeather
                    {
                        HighTemperature = daysData.list[i].main.temp_max,
                        LowTemperature  = daysData.list[i].main.temp_min,
                        IconId          = daysData.list[i].weather[0].icon,
                        WeatherType     = daysData.list[i].weather[0].main,
                        Time            = date.ToString("hh:mm:ss tt")
                    };
                    today.WeatherDays.Add(weather);
                }
            }
            return(today);
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------------
        //------------------------------End Current Weather-------------------------------
        //--------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------
        //---------------------------------Today's Weather--------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherDay FetchTodaysWether(Location location)
        {
            DaysWeatherData forecast = GetWeatherForecastData(location);
            WeatherDay      today    = null;

            if (forecast != null)
            {
                today = ProcessTodaysWeatherData(forecast);
            }
            return(today);
        }
Esempio n. 3
0
        //--------------------------------------------------------------------------------
        //-------------------------------End Today's Weather------------------------------
        //--------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------
        //-------------------------------Tomorrow's Weather-------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherDay FetchTomorrowsWeather(Location location)
        {
            //Read tomorrows weather data and process it into a Weather Day format
            DaysWeatherData forecast = GetWeatherForecastData(location);
            WeatherDay      tomorrow = null;

            if (forecast != null)
            {
                tomorrow = ProcessTomorrowsWeatherData(forecast);
            }
            return(tomorrow);
        }