bug fix:timezone error

This commit is contained in:
2021-03-04 17:27:33 +08:00
parent a9135de034
commit 407a63502b
7 changed files with 50 additions and 25 deletions
+12 -6
View File
@@ -111,6 +111,9 @@ func CulminationTime(date time.Time, lon, lat float64) float64 {
// lat,纬度,北正南负
func RiseTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
var err error
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
@@ -128,7 +131,7 @@ func RiseTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
if riseJde == -1 {
err = ERR_MOON_NEVER_DOWN
}
return basic.JDE2Date(riseJde), err
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 月亮降下时间
@@ -137,6 +140,9 @@ func RiseTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
// lat,纬度,北正南负
func DownTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
var err error
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
@@ -154,7 +160,7 @@ func DownTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
if downJde == -1 {
err = ERR_MOON_NEVER_DOWN
}
return basic.JDE2Date(downJde), err
return basic.JDE2DateByZone(downJde, date.Location(), true), err
}
// Phase 月相
@@ -167,25 +173,25 @@ func Phase(date time.Time) float64 {
// ShuoYue 朔月
func ShuoYue(year float64) time.Time {
jde := basic.TD2UT(basic.CalcMoonSH(year, 0), false)
return basic.JDE2DateByZone(jde, time.UTC)
return basic.JDE2DateByZone(jde, time.UTC, false)
}
// WangYue 望月
func WangYue(year float64) time.Time {
jde := basic.TD2UT(basic.CalcMoonSH(year, 1), false)
return basic.JDE2DateByZone(jde, time.UTC)
return basic.JDE2DateByZone(jde, time.UTC, false)
}
// ShangXianYue 上弦月
func ShangXianYue(year float64) time.Time {
jde := basic.TD2UT(basic.CalcMoonXH(year, 0), false)
return basic.JDE2DateByZone(jde, time.UTC)
return basic.JDE2DateByZone(jde, time.UTC, false)
}
// XiaXianYue 下弦月
func XiaXianYue(year float64) time.Time {
jde := basic.TD2UT(basic.CalcMoonXH(year, 1), false)
return basic.JDE2DateByZone(jde, time.UTC)
return basic.JDE2DateByZone(jde, time.UTC, false)
}
// EarthDistance 日地距离
+3 -6
View File
@@ -3,12 +3,9 @@ package moon
import (
"fmt"
"testing"
"time"
)
func TestMoonI(t *testing.T) {
fmt.Println(MoonR(2465445.9755443))
}
func Test_NewCalc(t *testing.T) {
fmt.Printf("%.14f", MoonCalcNew(2, 2451546.0))
func Test_Rise(t *testing.T) {
fmt.Println(RiseTime(time.Now(), 115, 32, true))
}