first functional version
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -25,25 +26,20 @@ func nextSunriseSunsetTime(t time.Time) (sunrise, sunset time.Time, err error) {
|
||||
return time.Time{}, time.Time{}, err
|
||||
}
|
||||
|
||||
var (
|
||||
nSR time.Time
|
||||
nSS time.Time
|
||||
)
|
||||
nSR := currentSR
|
||||
nSS := currentSS
|
||||
|
||||
if currentSR.After(t) {
|
||||
nSR = currentSR
|
||||
} else {
|
||||
if t.After(currentSR) {
|
||||
nSR = nextSR
|
||||
}
|
||||
|
||||
if currentSS.After(t) {
|
||||
nSS = currentSS
|
||||
} else {
|
||||
if t.After(currentSS) {
|
||||
nSS = nextSS
|
||||
}
|
||||
|
||||
log.Printf("[TRACE] Next calculated sunrise: %s\n", nSR.Format("2006-01-02 15:04:05"))
|
||||
log.Printf("[TRACE] Next calculated sunset : %s\n", nSS.Format("2006-01-02 15:04:05"))
|
||||
log.Printf("[TRACE] Calculated Time: %s\n", t.Format(config.TimeFormat))
|
||||
log.Printf("[TRACE] Next calculated sunrise: %s (%v)\n", nSR.Format(config.TimeFormat), math.Round(nSR.Sub(time.Now()).Seconds()))
|
||||
log.Printf("[TRACE] Next calculated sunset : %s (%v)\n", nSS.Format(config.TimeFormat), math.Round(nSS.Sub(time.Now()).Seconds()))
|
||||
|
||||
return nSR, nSS, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user