private static Collection <SunItem> CreateSunData(int year, double lat, double lon, TimeZoneInfo tzi = null)
        {
            var data = new Collection <SunItem>();
            var day  = new DateTime(year, 1, 1);

            while (day.Year == year)
            {
                var sunrise = Sun.Calculate(day, lat, lon, true, tzi);
                var sunset  = Sun.Calculate(day, lat, lon, false, tzi);
                data.Add(new SunItem {
                    Day = day, Sunrise = sunrise - day, Sunset = sunset - day
                });
                day = day.AddDays(1);
            }
            return(data);
        }
Exemple #2
0
        private static Collection <SunItem> CreateSunData(int year, double lat, double lon, Func <DateTime, DateTime> utcToLocalTime)
        {
            var data = new Collection <SunItem>();
            var day  = new DateTime(year, 1, 1);

            while (day.Year == year)
            {
                var sunrise = Sun.Calculate(day, lat, lon, true, utcToLocalTime);
                var sunset  = Sun.Calculate(day, lat, lon, false, utcToLocalTime);
                data.Add(new SunItem {
                    Day = day, Sunrise = sunrise - day, Sunset = sunset - day
                });
                day = day.AddDays(1);
            }

            return(data);
        }