Esempio n. 1
0
func isSunset(latitude float64, longitude float64) bool {
	t := astrotime.NextSunset(time.Now(), latitude, longitude)
	// tzname, _ := t.Zone()
	// fmt.Println(tzname)
	// fmt.Printf("The next sunrise is %d:%02d %s on %d/%d/%d.\n", t.Hour(), t.Minute(), tzname, t.Month(), t.Day(), t.Year())
	if t.Hour() == time.Now().Hour() && t.Minute() == time.Now().Minute() {
		return true
	}
	return false
}
Esempio n. 2
0
//sunset/runrise
func getSun(p string) string {

	var t time.Time
	switch p {
	case "set":
		t = astrotime.NextSunset(time.Now(), float64(56.878333), float64(14.809167))
		break
	case "rise":
		t = astrotime.NextSunrise(time.Now(), float64(56.878333), float64(14.809167))
		break
	}

	padHour := ""
	padMinute := ""
	if t.Hour() < 10 {
		padHour = "0"
	}
	if t.Minute() < 10 {
		padMinute = "0"
	}
	ti := padHour + strconv.Itoa(t.Hour()) + ":" + padMinute + strconv.Itoa(t.Minute())
	return ti
	//return "{\"type\":\"sunset\",\"value\":\"" + ti + "\"}"
}