public static DateTime UtcSunrise(this SunTracker tracker) { var sunriseJulianDate = tracker.SolarTransit - (tracker.HourAngle / 360.0); var sunriseUtcGregorianDate = JulianDateConverter.CalculateGregorianDate(sunriseJulianDate, tracker.GregorianDate, tracker.JulianDate); return(sunriseUtcGregorianDate); }
public static DateTime Sunset(this SunTracker tracker, TimeSpan offset) { var sunriseUtcGregorianDate = UtcSunset(tracker); var sunrisetLocalGregorianDate = sunriseUtcGregorianDate.Add(offset); return(sunrisetLocalGregorianDate); }
public static DateTime Sunset(this SunTracker tracker, TimeSpan offset, bool dayLightSaving) { var sunriseUtcGregorianDate = UtcSunset(tracker); var sunrisetLocalGregorianDate = sunriseUtcGregorianDate.Add(offset); sunrisetLocalGregorianDate = dayLightSaving ? sunrisetLocalGregorianDate.AddHours(1) : sunrisetLocalGregorianDate; return(sunrisetLocalGregorianDate); }
public static SunTimes Times(double latitude, double longitude, DateTime?theDate = null, TimeSpan?offset = null, bool dst = false) { var timestamp = theDate ?? DateTime.UtcNow; var zoneOffset = offset ?? TimeSpan.Zero; var tracker = new SunTracker(latitude, longitude, timestamp); return(new SunTimes { Local = new SunRiseSet { Rise = tracker.Sunrise(zoneOffset, dst), Set = tracker.Sunset(zoneOffset, dst) }.ToSolarDay(), UTC = new SunRiseSet { Rise = tracker.UTCSunrise(), Set = tracker.UTCSunset() }.ToSolarDay(), }); }