- fix: Correct sun.TrueBo calculation, now using basic.HSunTrueBo for correct solar latitude

- fix: Rename GetSunDownTime to GetSunSetTime in basic/sun.go and update related calls/outputs
- fix: Update test cases to use new method and error constant names

- improve: Rename all DownTime/Down functions to SetTime/Set for consistency
- improve: Standardize ERR_XXX_NEVER_DOWN error constants to ERR_XXX_NEVER_SET, with ERR_XXX_NEVER_DOWN kept as compatibility alias
- improve: More standard naming for interfaces and errors to improve maintainability and readability
This commit is contained in:
2025-09-08 10:37:46 +08:00
parent b0920d327c
commit 4302981518
22 changed files with 168 additions and 82 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ package sun
import (
"fmt"
"math"
"testing"
"time"
)
@@ -22,8 +23,12 @@ func TestSun(t *testing.T) {
if d.Format("2006-01-02 15:04:05") != "2020-01-01 08:41:45" {
t.Fatal(d.Format("2006-01-02 15:04:05"))
}
bo := TrueBo(now)
if math.Abs(bo) > 2 {
t.Fatal(bo)
}
fmt.Println(CulminationTime(now, 115))
fmt.Println(DownTime(now, 115, 40, 0, true))
fmt.Println(SetTime(now, 115, 40, 0, true))
fmt.Println(MorningTwilight(now, 115, 40, -6))
fmt.Println(EveningTwilight(now, 115, 40, -6))
}