diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 183738e..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 数据源本地存储已忽略文件 -/../../../../../../:\gocode\src\b612.me\astro\.idea/dataSources/ -/dataSources.local.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ diff --git a/.idea/astro.iml b/.idea/astro.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/astro.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e85cb08..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/basic/calendar_test.go b/basic/calendar_test.go index 30bb633..df16372 100644 --- a/basic/calendar_test.go +++ b/basic/calendar_test.go @@ -5,8 +5,12 @@ import ( "fmt" "math" "os" + "testing" ) +func TestGenerateMagic(t *testing.T) { + generateMagicNumber() +} func generateMagicNumber() { //0月份 00000 日期 0000闰月 0000000000000 农历信息 var tz = 8.0000 / 24.000 @@ -14,6 +18,7 @@ func generateMagicNumber() { spYear := make(map[int][]int) var upper []uint16 var lower []uint16 + var full []uint32 //var info uint32 = 0 for year := 1899; year <= 2401; year++ { fmt.Println(year) @@ -89,13 +94,16 @@ func generateMagicNumber() { } for year := 1900; year <= 2400; year++ { fmt.Println(year) - up, low := magicNumberSpilt(magicNumber(yearMap[year], spYear[year])) + magic := magicNumber(yearMap[year], spYear[year]) + up, low := magicNumberSpilt(magic) upper = append(upper, up) lower = append(lower, uint16(low)) + full = append(full, uint32(magic)) } res := make(map[string]interface{}) res["up"] = upper res["low"] = lower + res["full"] = full d, _ := json.Marshal(res) os.WriteFile("test.json", d, 0644) } diff --git a/basic/sun_test.go b/basic/sun_test.go index 8d2353a..b0a17db 100644 --- a/basic/sun_test.go +++ b/basic/sun_test.go @@ -4,6 +4,7 @@ import ( "b612.me/astro/tools" "fmt" "math" + "os" "testing" "time" ) @@ -162,17 +163,20 @@ func TestJQDate(t *testing.T) { return math.Floor(d) + 0.5 } c := 0 + var info string for year := 1900; year <= 2600; year++ { for pos := 0; pos < 360; pos += 15 { - n := newGetJQTime(year, pos) - o := GetJQTime(year, pos) + n := newGetJQTime(year, pos) + 8.0/24.000000 + o := GetJQTime(year, pos) + 8.0/24.0000000 if trimDay(n) != trimDay(o) { c++ - fmt.Printf("\"%d%03d\":%.0f,", year, pos, trimDay(o)-trimDay(n)) + fmt.Printf("\"%d%03d\"=>%v %v\n", year, pos, JDE2Date(trimDay(o)), JDE2Date(trimDay(n))) + info += fmt.Sprintf("\"%d%03d\"=>%.0f,", year, pos, trimDay(o)-trimDay(n)) } } } fmt.Println(c) + os.WriteFile("test.txt", []byte(info), 0644) } func newGetJQTime(Year, Angle int) float64 { //节气时间 diff --git a/calendar/chinese.go b/calendar/chinese.go index d7fdb32..985e1d7 100644 --- a/calendar/chinese.go +++ b/calendar/chinese.go @@ -143,9 +143,6 @@ recalc: magic := int32(upper[idx])<<8 + int32(lower[idx]) springMonth := (magic&0x800000)>>23 + 1 springDay := (magic & 0x7FFFFF) >> 18 - if springMonth == int32(month) && springDay == int32(day) { - return 1, 1, false, "正月初一" - } if !useGoto && (springMonth > int32(month) || (springMonth == int32(month) && springDay > int32(day))) { year-- useGoto = true diff --git a/tools/math.go b/tools/math.go index ca91d05..adf64a0 100644 --- a/tools/math.go +++ b/tools/math.go @@ -34,10 +34,8 @@ func FloatRound(f float64, n int) float64 { } func Limit360(x float64) float64 { - for x > 360 { - x -= 360 - } - for x < 0 { + x = math.Mod(x, 360) + if x < 0 { x += 360 } return x