Beispiel #1
0
func (clk *systemclock) Dusk(ref time.Time) time.Time {
	if !clk.useCoordinates {
		dusk := time.Date(ref.Year(), ref.Month(), ref.Day(), 6, 0, 0, 0, ref.Location())
		if dusk.Sub(ref) < 0 {
			dusk = dusk.AddDate(0, 0, 1)
		}
		return dusk
	}
	return astrotime.NextDusk(ref, clk.latitude, clk.longtitude, astrotime.CIVIL_DUSK)
}
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)
}