Exemple #1
0
func (clk *systemclock) Sunset(ref time.Time) time.Time {
	if !clk.useCoordinates {
		sunset := time.Date(ref.Year(), ref.Month(), ref.Day(), 18, 0, 0, 0, ref.Location())
		if sunset.Sub(ref) < 0 {
			sunset = sunset.AddDate(0, 0, 1)
		}
		return sunset
	}
	return astrotime.NextSunset(ref, clk.latitude, clk.longtitude)
}
func getTime(s string) (time.Time, error) {

	midnight, _ := parseTimeToday("00:00")

	switch s {
	case "dawn":
		return astrotime.NextDawn(midnight, latitude, longitude, astrotime.CIVIL_DAWN), nil
	case "sunrise":
		return astrotime.NextSunrise(midnight, latitude, longitude), nil
	case "sunset":
		return astrotime.NextSunset(midnight, latitude, longitude), nil
	case "dusk":
		return astrotime.NextDusk(midnight, latitude, longitude, astrotime.CIVIL_DUSK), nil
	}

	return parseTimeToday(s)
}