예제 #1
0
파일: clock.go 프로젝트: froz/app-scheduler
func (clk *systemclock) Sunrise(ref time.Time) time.Time {
	if !clk.useCoordinates {
		sunrise := time.Date(ref.Year(), ref.Month(), ref.Day(), 6, 0, 0, 0, ref.Location())
		if sunrise.Sub(ref) < 0 {
			sunrise = sunrise.AddDate(0, 0, 1)
		}
		return sunrise
	}
	return astrotime.NextSunrise(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)
}