bug fix:解决非东八区的农历计算不正确的问题
This commit is contained in:
parent
ebdcf65c46
commit
6b97736829
@ -235,8 +235,8 @@ func GetLunar(year, month, day int, tz float64) (lmonth, lday int, leap bool, re
|
||||
}
|
||||
jieqi := GetOneYearJQ(year) //一年的节气
|
||||
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
||||
winter1 := jieqi[1] //第一年冬至日
|
||||
winter2 := jieqi[25] //第二年冬至日
|
||||
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
|
||||
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
|
||||
for k, v := range moon {
|
||||
if tz != 8.0/24 {
|
||||
v = v - 8.0/24 + tz
|
||||
@ -334,8 +334,8 @@ func GetSolar(year, month, day int, leap bool, tz float64) float64 {
|
||||
}
|
||||
jieqi := GetOneYearJQ(year) //一年的节气
|
||||
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
||||
winter1 := jieqi[1] //第一年冬至日
|
||||
winter2 := jieqi[25] //第二年冬至日
|
||||
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
|
||||
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
|
||||
for k, v := range moon {
|
||||
if tz != 8.0/24 {
|
||||
v = v - 8.0/24 + tz
|
||||
|
@ -39,7 +39,7 @@ const (
|
||||
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
||||
// 古代由于定朔定气误差此处计算会与古时不符
|
||||
func Lunar(year, month, day int, timezone float64) (int, int, bool, string) {
|
||||
return basic.GetLunar(year, month, day, timezone)
|
||||
return basic.GetLunar(year, month, day, timezone/24.0)
|
||||
}
|
||||
|
||||
// Solar 农历转公历
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type LunarSolar struct {
|
||||
type lunarSolar struct {
|
||||
Lyear int
|
||||
Lmonth int
|
||||
Lday int
|
||||
@ -16,7 +16,7 @@ type LunarSolar struct {
|
||||
}
|
||||
|
||||
func Test_ChineseCalendar(t *testing.T) {
|
||||
var testData = []LunarSolar{
|
||||
var testData = []lunarSolar{
|
||||
{Lyear: 2034, Lmonth: 1, Lday: 1, Leap: false, Year: 2034, Month: 2, Day: 19},
|
||||
{Lyear: 2033, Lmonth: 12, Lday: 30, Leap: false, Year: 2034, Month: 2, Day: 18},
|
||||
{Lyear: 2033, Lmonth: 11, Lday: 27, Leap: true, Year: 2034, Month: 1, Day: 17},
|
||||
@ -37,7 +37,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
||||
}
|
||||
for _, v := range testData {
|
||||
var lyear int = v.Year
|
||||
lmonth, lday, leap, desp := Lunar(v.Year, v.Month, v.Day)
|
||||
lmonth, lday, leap, desp := Lunar(v.Year, v.Month, v.Day, 8.0)
|
||||
if lmonth > v.Month {
|
||||
lyear--
|
||||
}
|
||||
@ -46,7 +46,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
||||
t.Fatal(v, lyear, lmonth, lday, leap, desp)
|
||||
}
|
||||
|
||||
date := Solar(v.Lyear, v.Lmonth, v.Lday, v.Leap)
|
||||
date := Solar(v.Lyear, v.Lmonth, v.Lday, v.Leap, 8.0)
|
||||
if date.Year() != v.Year || int(date.Month()) != v.Month || date.Day() != v.Day {
|
||||
t.Fatal(v, date)
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ func ApparentSiderealTime(date time.Time) float64 {
|
||||
}
|
||||
|
||||
// RiseTime 星星升起时间
|
||||
//
|
||||
// date, 世界时(忽略此处时区)
|
||||
// ra,Date瞬时赤经
|
||||
// dec,Date瞬时赤纬
|
||||
@ -57,6 +58,7 @@ func RiseTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (tim
|
||||
}
|
||||
|
||||
// DownTime 星星升起时间
|
||||
//
|
||||
// date, 世界时(忽略此处时区)
|
||||
// ra,Date瞬时赤经
|
||||
// dec,Date瞬时赤纬
|
||||
@ -106,7 +108,7 @@ func Zenith(date time.Time, ra, dec, lon, lat float64) float64 {
|
||||
jde := basic.Date2JDE(date)
|
||||
_, loc := date.Zone()
|
||||
timezone := float64(loc) / 3600.0
|
||||
return basic.StarAzimuth(jde, ra, dec, lon, lat, timezone)
|
||||
return basic.StarHeight(jde, ra, dec, lon, lat, timezone)
|
||||
}
|
||||
|
||||
// CulminationTime 恒星中天时间
|
||||
|
Loading…
x
Reference in New Issue
Block a user