2022-05-16 20:42:15 +08:00
|
|
|
package neptune
|
|
|
|
|
|
|
|
|
|
import (
|
2026-05-22 12:24:41 +08:00
|
|
|
"math"
|
2022-05-16 20:42:15 +08:00
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-22 12:24:41 +08:00
|
|
|
func sameUnixSecond(got time.Time, want int64) bool {
|
|
|
|
|
return math.Abs(float64(got.Unix()-want)) <= 1
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-16 20:42:15 +08:00
|
|
|
func TestNeptune(t *testing.T) {
|
2024-10-26 21:28:26 +08:00
|
|
|
tz := time.FixedZone("CST", 8*3600)
|
|
|
|
|
date := time.Date(2022, 01, 20, 00, 00, 00, 00, tz)
|
2026-05-22 12:24:41 +08:00
|
|
|
if !sameUnixSecond(NextConjunction(date), 1647171800) {
|
2024-10-26 21:28:26 +08:00
|
|
|
t.Fatal(NextConjunction(date).Unix())
|
|
|
|
|
}
|
|
|
|
|
if CulminationTime(date, 115).Unix() != 1642665021 {
|
|
|
|
|
t.Fatal(CulminationTime(date, 115).Unix())
|
|
|
|
|
}
|
|
|
|
|
date, err := (RiseTime(date, 115, 40, 0, false))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if date.Unix() != 1642644398 {
|
|
|
|
|
t.Fatal(date.Unix())
|
|
|
|
|
}
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|