fix:时区转换问题

This commit is contained in:
2024-10-26 21:28:26 +08:00
parent d479d39352
commit 616cd54222
7 changed files with 81 additions and 44 deletions
+3
View File
@@ -209,11 +209,14 @@ func Phase(date time.Time) float64 {
}
// ShuoYue 朔月
// 返回Date对应UTC世界时的月相大小
func ShuoYue(year float64) time.Time {
jde := basic.TD2UT(basic.CalcMoonSH(year, 0), false)
return basic.JDE2DateByZone(jde, time.UTC, false)
}
// NextShuoYue 下次朔月时间
// 返回date之后的下一个朔月时间(UTC时间)
func NextShuoYue(date time.Time) time.Time {
return nextMoonPhase(date, 0)
}
+12 -19
View File
@@ -13,38 +13,38 @@ func Test_MoonPhaseDate(t *testing.T) {
//指定日期后的下一个朔月
moonPhase01 := NextShuoYue(date)
fmt.Println("下一朔月", moonPhase01)
if moonPhase01.Unix() != 1643694349 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1643694356 {
t.Fatal(moonPhase01.Unix())
}
//指定日期后的上一个朔月
moonPhase01 = LastShuoYue(date)
fmt.Println("上一朔月", moonPhase01)
if moonPhase01.Unix() != 1641148399 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1641148406 {
t.Fatal(moonPhase01.Unix())
}
//离指定日期最近的朔月
moonPhase01 = ClosestShuoYue(date)
fmt.Println("最近朔月", moonPhase01)
if moonPhase01.Unix() != 1643694349 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1643694356 {
t.Fatal(moonPhase01.Unix())
}
//离指定日期最近的望月时间
moonPhase01 = ClosestWangYue(date)
fmt.Println("最近望月", moonPhase01)
if moonPhase01.Unix() != 1642463294 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1642463301 {
t.Fatal(moonPhase01.Unix())
}
//离指定日期最近的上弦月时间
moonPhase01 = ClosestShangXianYue(date)
fmt.Println("最近上弦月", moonPhase01)
if moonPhase01.Unix() != 1641751864 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1641751871 {
t.Fatal(moonPhase01.Unix())
}
//离指定日期最近的下弦月时间
moonPhase01 = ClosestXiaXianYue(date)
fmt.Println("最近下弦月", moonPhase01)
if moonPhase01.Unix() != 1643118043 {
t.Fatal(moonPhase01)
if moonPhase01.Unix() != 1643118050 {
t.Fatal(moonPhase01.Unix())
}
//-------------------
for i := 0; i < 26; i++ {
@@ -52,10 +52,3 @@ func Test_MoonPhaseDate(t *testing.T) {
fmt.Println("上一朔月", moonPhase01)
}
}
func TestMoon(t *testing.T) {
now := time.Now()
fmt.Println(RiseTime(now, 115, 40, 0, true))
fmt.Println(CulminationTime(now, 115, 40))
fmt.Println(DownTime(now, 115, 40, 0, true))
}