bug fix:解决非东八区的农历计算不正确的问题
This commit is contained in:
parent
ebdcf65c46
commit
6b97736829
@ -8,9 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@name: 儒略日计算
|
@name: 儒略日计算
|
||||||
@dec: 计算给定时间的儒略日,1582年改力后为格里高利历,之前为儒略历
|
@dec: 计算给定时间的儒略日,1582年改力后为格里高利历,之前为儒略历
|
||||||
@ 请注意,传入的时间在天文计算中一般为力学时,应当注意和世界时的转化
|
@ 请注意,传入的时间在天文计算中一般为力学时,应当注意和世界时的转化
|
||||||
*/
|
*/
|
||||||
func JDECalc(Year, Month int, Day float64) float64 {
|
func JDECalc(Year, Month int, Day float64) float64 {
|
||||||
if Month == 1 || Month == 2 {
|
if Month == 1 || Month == 2 {
|
||||||
@ -29,7 +29,7 @@ func JDECalc(Year, Month int, Day float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@name: 获得当前儒略日时间:当地世界时,非格林尼治时间
|
@name: 获得当前儒略日时间:当地世界时,非格林尼治时间
|
||||||
*/
|
*/
|
||||||
func GetNowJDE() (NowJDE float64) {
|
func GetNowJDE() (NowJDE float64) {
|
||||||
Time := float64(time.Now().Second())/3600.0/24.0 + float64(time.Now().Minute())/60.0/24.0 + float64(time.Now().Hour())/24.0
|
Time := float64(time.Now().Second())/3600.0/24.0 + float64(time.Now().Minute())/60.0/24.0 + float64(time.Now().Hour())/24.0
|
||||||
@ -235,8 +235,8 @@ func GetLunar(year, month, day int, tz float64) (lmonth, lday int, leap bool, re
|
|||||||
}
|
}
|
||||||
jieqi := GetOneYearJQ(year) //一年的节气
|
jieqi := GetOneYearJQ(year) //一年的节气
|
||||||
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
||||||
winter1 := jieqi[1] //第一年冬至日
|
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
|
||||||
winter2 := jieqi[25] //第二年冬至日
|
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
|
||||||
for k, v := range moon {
|
for k, v := range moon {
|
||||||
if tz != 8.0/24 {
|
if tz != 8.0/24 {
|
||||||
v = v - 8.0/24 + tz
|
v = v - 8.0/24 + tz
|
||||||
@ -334,8 +334,8 @@ func GetSolar(year, month, day int, leap bool, tz float64) float64 {
|
|||||||
}
|
}
|
||||||
jieqi := GetOneYearJQ(year) //一年的节气
|
jieqi := GetOneYearJQ(year) //一年的节气
|
||||||
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
moon := GetOneYearMoon(float64(year)) //一年朔月日
|
||||||
winter1 := jieqi[1] //第一年冬至日
|
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
|
||||||
winter2 := jieqi[25] //第二年冬至日
|
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
|
||||||
for k, v := range moon {
|
for k, v := range moon {
|
||||||
if tz != 8.0/24 {
|
if tz != 8.0/24 {
|
||||||
v = v - 8.0/24 + tz
|
v = v - 8.0/24 + tz
|
||||||
|
@ -39,7 +39,7 @@ const (
|
|||||||
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
||||||
// 古代由于定朔定气误差此处计算会与古时不符
|
// 古代由于定朔定气误差此处计算会与古时不符
|
||||||
func Lunar(year, month, day int, timezone float64) (int, int, bool, string) {
|
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 农历转公历
|
// Solar 农历转公历
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LunarSolar struct {
|
type lunarSolar struct {
|
||||||
Lyear int
|
Lyear int
|
||||||
Lmonth int
|
Lmonth int
|
||||||
Lday int
|
Lday int
|
||||||
@ -16,7 +16,7 @@ type LunarSolar struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_ChineseCalendar(t *testing.T) {
|
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: 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: 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},
|
{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 {
|
for _, v := range testData {
|
||||||
var lyear int = v.Year
|
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 {
|
if lmonth > v.Month {
|
||||||
lyear--
|
lyear--
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
|||||||
t.Fatal(v, lyear, lmonth, lday, leap, desp)
|
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 {
|
if date.Year() != v.Year || int(date.Month()) != v.Month || date.Day() != v.Day {
|
||||||
t.Fatal(v, date)
|
t.Fatal(v, date)
|
||||||
}
|
}
|
||||||
|
36
star/star.go
36
star/star.go
@ -20,7 +20,7 @@ func Constellation(ra, dec float64, date time.Time) string {
|
|||||||
return basic.WhichCst(ra, dec, jde)
|
return basic.WhichCst(ra, dec, jde)
|
||||||
}
|
}
|
||||||
|
|
||||||
//MeanSiderealTime UTC 平恒星时
|
// MeanSiderealTime UTC 平恒星时
|
||||||
func MeanSiderealTime(date time.Time) float64 {
|
func MeanSiderealTime(date time.Time) float64 {
|
||||||
return basic.MeanSiderealTime(basic.Date2JDE(date.UTC()))
|
return basic.MeanSiderealTime(basic.Date2JDE(date.UTC()))
|
||||||
}
|
}
|
||||||
@ -31,13 +31,14 @@ func ApparentSiderealTime(date time.Time) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RiseTime 星星升起时间
|
// RiseTime 星星升起时间
|
||||||
// date, 世界时(忽略此处时区)
|
//
|
||||||
// ra,Date瞬时赤经
|
// date, 世界时(忽略此处时区)
|
||||||
// dec,Date瞬时赤纬
|
// ra,Date瞬时赤经
|
||||||
// lon,经度,东正西负
|
// dec,Date瞬时赤纬
|
||||||
// lat,纬度,北正南负
|
// lon,经度,东正西负
|
||||||
// height,高度
|
// lat,纬度,北正南负
|
||||||
// aero,是否进行大气修正
|
// height,高度
|
||||||
|
// aero,是否进行大气修正
|
||||||
func RiseTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
|
func RiseTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
|
||||||
var err error
|
var err error
|
||||||
if date.Hour() > 12 {
|
if date.Hour() > 12 {
|
||||||
@ -57,13 +58,14 @@ func RiseTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (tim
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DownTime 星星升起时间
|
// DownTime 星星升起时间
|
||||||
// date, 世界时(忽略此处时区)
|
//
|
||||||
// ra,Date瞬时赤经
|
// date, 世界时(忽略此处时区)
|
||||||
// dec,Date瞬时赤纬
|
// ra,Date瞬时赤经
|
||||||
// lon,经度,东正西负
|
// dec,Date瞬时赤纬
|
||||||
// lat,纬度,北正南负
|
// lon,经度,东正西负
|
||||||
// height,高度
|
// lat,纬度,北正南负
|
||||||
// aero,是否进行大气修正
|
// height,高度
|
||||||
|
// aero,是否进行大气修正
|
||||||
func DownTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
|
func DownTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
|
||||||
var err error
|
var err error
|
||||||
if date.Hour() > 12 {
|
if date.Hour() > 12 {
|
||||||
@ -106,7 +108,7 @@ func Zenith(date time.Time, ra, dec, lon, lat float64) float64 {
|
|||||||
jde := basic.Date2JDE(date)
|
jde := basic.Date2JDE(date)
|
||||||
_, loc := date.Zone()
|
_, loc := date.Zone()
|
||||||
timezone := float64(loc) / 3600.0
|
timezone := float64(loc) / 3600.0
|
||||||
return basic.StarAzimuth(jde, ra, dec, lon, lat, timezone)
|
return basic.StarHeight(jde, ra, dec, lon, lat, timezone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CulminationTime 恒星中天时间
|
// CulminationTime 恒星中天时间
|
||||||
@ -127,7 +129,7 @@ func InitStarDatabase() error {
|
|||||||
return basic.LoadStarData()
|
return basic.LoadStarData()
|
||||||
}
|
}
|
||||||
|
|
||||||
//通过恒星HR编号获取恒星参数
|
// 通过恒星HR编号获取恒星参数
|
||||||
func GetStarDataByHR(hr int) (basic.StarData, error) {
|
func GetStarDataByHR(hr int) (basic.StarData, error) {
|
||||||
return basic.StarDataByHR(hr)
|
return basic.StarDataByHR(hr)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user