2021-12-09 16:28:45 -06:00

35 lines
661 B
Go

package main
import (
"fmt"
"log"
"math"
"os"
"time"
)
func main() {
initialize()
_, _, err := nextSunriseSunsetTime(config.CalculateDate)
if err != nil {
log.Fatalf("[ERROR] Unable to calculate sunrise/sunset: %v\n", err)
}
if config.NextSunrise || config.NextSunset {
sR, sS, err := nextSunriseSunsetTime(config.SunRiseSet.Date)
if err != nil {
runError(fmt.Sprintf("Unable to calculate sunrise/sunset: %v\n", err))
}
switch {
case config.NextSunrise:
fmt.Printf("%v\n", math.Round(sR.Sub(time.Now()).Seconds()))
case config.NextSunset:
fmt.Printf("%v\n", math.Round(sS.Sub(time.Now()).Seconds()))
}
os.Exit(0)
}
}