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
+7 -4
View File
@@ -169,7 +169,7 @@ func JDE2Date(JD float64) time.Time {
return dates
}
func JDE2DateByZone(JD float64, tz *time.Location) time.Time {
func JDE2DateByZone(JD float64, tz *time.Location, byZone bool) time.Time {
JD = JD + 0.5
Z := float64(int(JD))
F := JD - Z
@@ -199,9 +199,12 @@ func JDE2DateByZone(JD float64, tz *time.Location) time.Time {
}
tms := (Days - math.Floor(Days)) * 24 * 3600
Days = math.Floor(Days)
dates := time.Date(int(Years), time.Month(int(Months)), int(Days), 0, 0, 0, 0, time.UTC)
dates = time.Unix(dates.Unix()+int64(tms), int64((tms-math.Floor(tms))*1000000000)).In(tz)
return dates
if !byZone {
dates := time.Date(int(Years), time.Month(int(Months)), int(Days), 0, 0, 0, 0, time.UTC)
return time.Unix(dates.Unix()+int64(tms), int64((tms-math.Floor(tms))*1000000000)).In(tz)
}
dates := time.Date(int(Years), time.Month(int(Months)), int(Days), 0, 0, 0, 0, tz)
return time.Unix(dates.Unix()+int64(tms), int64((tms-math.Floor(tms))*1000000000))
}
func GetLunar(year, month, day int) (lmonth, lday int, leap bool, result string) {
+5 -3
View File
@@ -1402,7 +1402,8 @@ func GetMoonRiseTime(JD, Lon, Lat, TZ, ZS float64) float64 {
ntz := TZ
TZ = Lon / 15
var An, tms float64 = 0, 0
JD = math.Floor(JD) + 0.5 - ntz/24 + TZ/24 //求0时JDE
JDZ := math.Floor(JD) + 0.5
JD = math.Floor(JD) + 0.5 - ntz/24 + TZ/24.0 //求0时JDE
JD1 := JD
moonheight := MoonHeight(JD, Lon, Lat, TZ) //求此时月亮高度
if ZS != 0 {
@@ -1453,7 +1454,7 @@ func GetMoonRiseTime(JD, Lon, Lat, TZ, ZS float64) float64 {
}
JD1 = JD1 - TZ/24 + ntz/24
if JD1 > JD+1 || JD1 < JD {
if JD1 > JDZ+1 || JD1 < JDZ {
return -3 //明日
} else {
return JD1
@@ -1464,6 +1465,7 @@ func GetMoonDownTime(JD, Lon, Lat, TZ, ZS float64) float64 {
ntz := TZ
TZ = Lon / 15
var An, tms float64 = 0, 0
JDZ := math.Floor(JD) + 0.5
JD = math.Floor(JD) + 0.5 - ntz/24 + TZ/24 //求0时JDE
JD1 := JD
moonheight := MoonHeight(JD, Lon, Lat, TZ) //求此时月亮高度
@@ -1511,7 +1513,7 @@ func GetMoonDownTime(JD, Lon, Lat, TZ, ZS float64) float64 {
}
}
JD1 = JD1 - TZ/24 + ntz/24
if JD1 > JD+1 || JD1 < JD {
if JD1 > JDZ+1 || JD1 < JDZ {
return -3 //明日
} else {
return JD1