master
兔子 2 days ago
parent d479d39352
commit 1952df0c30

1
.gitignore vendored

@ -0,0 +1 @@
.idea

8
.idea/.gitignore vendored

@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 数据源本地存储已忽略文件
/../../../../../../:\gocode\src\b612.me\astro\.idea/dataSources/
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/astro.iml" filepath="$PROJECT_DIR$/.idea/astro.iml" />
</modules>
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -5,8 +5,12 @@ import (
"fmt" "fmt"
"math" "math"
"os" "os"
"testing"
) )
func TestGenerateMagic(t *testing.T) {
generateMagicNumber()
}
func generateMagicNumber() { func generateMagicNumber() {
//0月份 00000 日期 0000闰月 0000000000000 农历信息 //0月份 00000 日期 0000闰月 0000000000000 农历信息
var tz = 8.0000 / 24.000 var tz = 8.0000 / 24.000
@ -14,6 +18,7 @@ func generateMagicNumber() {
spYear := make(map[int][]int) spYear := make(map[int][]int)
var upper []uint16 var upper []uint16
var lower []uint16 var lower []uint16
var full []uint32
//var info uint32 = 0 //var info uint32 = 0
for year := 1899; year <= 2401; year++ { for year := 1899; year <= 2401; year++ {
fmt.Println(year) fmt.Println(year)
@ -89,13 +94,16 @@ func generateMagicNumber() {
} }
for year := 1900; year <= 2400; year++ { for year := 1900; year <= 2400; year++ {
fmt.Println(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) upper = append(upper, up)
lower = append(lower, uint16(low)) lower = append(lower, uint16(low))
full = append(full, uint32(magic))
} }
res := make(map[string]interface{}) res := make(map[string]interface{})
res["up"] = upper res["up"] = upper
res["low"] = lower res["low"] = lower
res["full"] = full
d, _ := json.Marshal(res) d, _ := json.Marshal(res)
os.WriteFile("test.json", d, 0644) os.WriteFile("test.json", d, 0644)
} }

@ -4,6 +4,7 @@ import (
"b612.me/astro/tools" "b612.me/astro/tools"
"fmt" "fmt"
"math" "math"
"os"
"testing" "testing"
"time" "time"
) )
@ -162,17 +163,20 @@ func TestJQDate(t *testing.T) {
return math.Floor(d) + 0.5 return math.Floor(d) + 0.5
} }
c := 0 c := 0
var info string
for year := 1900; year <= 2600; year++ { for year := 1900; year <= 2600; year++ {
for pos := 0; pos < 360; pos += 15 { for pos := 0; pos < 360; pos += 15 {
n := newGetJQTime(year, pos) n := newGetJQTime(year, pos) + 8.0/24.000000
o := GetJQTime(year, pos) o := GetJQTime(year, pos) + 8.0/24.0000000
if trimDay(n) != trimDay(o) { if trimDay(n) != trimDay(o) {
c++ 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) fmt.Println(c)
os.WriteFile("test.txt", []byte(info), 0644)
} }
func newGetJQTime(Year, Angle int) float64 { //节气时间 func newGetJQTime(Year, Angle int) float64 { //节气时间

@ -143,9 +143,6 @@ recalc:
magic := int32(upper[idx])<<8 + int32(lower[idx]) magic := int32(upper[idx])<<8 + int32(lower[idx])
springMonth := (magic&0x800000)>>23 + 1 springMonth := (magic&0x800000)>>23 + 1
springDay := (magic & 0x7FFFFF) >> 18 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))) { if !useGoto && (springMonth > int32(month) || (springMonth == int32(month) && springDay > int32(day))) {
year-- year--
useGoto = true useGoto = true

@ -34,10 +34,8 @@ func FloatRound(f float64, n int) float64 {
} }
func Limit360(x float64) float64 { func Limit360(x float64) float64 {
for x > 360 { x = math.Mod(x, 360)
x -= 360 if x < 0 {
}
for x < 0 {
x += 360 x += 360
} }
return x return x

Loading…
Cancel
Save