コード例 #1
0
ファイル: clock.go プロジェクト: froz/app-scheduler
func (clk *systemclock) Dawn(ref time.Time) time.Time {
	if !clk.useCoordinates {
		dawn := time.Date(ref.Year(), ref.Month(), ref.Day(), 18, 0, 0, 0, ref.Location())
		if dawn.Sub(ref) < 0 {
			dawn = dawn.AddDate(0, 0, 1)
		}
		return dawn
	}
	return astrotime.NextDawn(ref, clk.latitude, clk.longtitude, astrotime.CIVIL_DAWN)
}
コード例 #2
0
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)
}