Compare commits
3 Commits
v0.0.3
...
94aeb84da5
| Author | SHA1 | Date | |
|---|---|---|---|
| 94aeb84da5 | |||
| 1952df0c30 | |||
| b0920d327c |
@@ -0,0 +1 @@
|
|||||||
|
.idea
|
||||||
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
# 默认忽略的文件
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# 数据源本地存储已忽略文件
|
|
||||||
/../../../../../../:\gocode\src\b612.me\astro\.idea/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
|
||||||
/httpRequests/
|
|
||||||
Generated
-9
@@ -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>
|
|
||||||
Generated
-8
@@ -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>
|
|
||||||
Generated
-6
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-3
@@ -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 { //节气时间
|
||||||
|
|||||||
+1
-1
@@ -143,7 +143,7 @@ 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) {
|
if !useGoto && springMonth == int32(month) && springDay == int32(day) {
|
||||||
return 1, 1, false, "正月初一"
|
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))) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type lunarSolar struct {
|
|||||||
|
|
||||||
func Test_ChineseCalendar(t *testing.T) {
|
func Test_ChineseCalendar(t *testing.T) {
|
||||||
var testData = []lunarSolar{
|
var testData = []lunarSolar{
|
||||||
|
{Lyear: 1995, Lmonth: 12, Lday: 12, Leap: false, Year: 1996, Month: 1, Day: 31},
|
||||||
{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,6 +38,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
|||||||
{Lyear: 2021, Lmonth: 12, Lday: 29, Leap: false, Year: 2022, Month: 1, Day: 31},
|
{Lyear: 2021, Lmonth: 12, Lday: 29, Leap: false, Year: 2022, Month: 1, Day: 31},
|
||||||
}
|
}
|
||||||
for _, v := range testData {
|
for _, v := range testData {
|
||||||
|
{
|
||||||
var lyear int = v.Year
|
var lyear int = v.Year
|
||||||
lmonth, lday, leap, desp := SolarToLunar(time.Date(v.Year, time.Month(v.Month), v.Day, 0, 0, 0, 0, time.Local))
|
lmonth, lday, leap, desp := SolarToLunar(time.Date(v.Year, time.Month(v.Month), v.Day, 0, 0, 0, 0, time.Local))
|
||||||
if lmonth > v.Month {
|
if lmonth > v.Month {
|
||||||
@@ -52,4 +54,21 @@ func Test_ChineseCalendar(t *testing.T) {
|
|||||||
t.Fatal(v, date)
|
t.Fatal(v, date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
var lyear int = v.Year
|
||||||
|
lmonth, lday, leap, desp := RapidSolarToLunar(time.Date(v.Year, time.Month(v.Month), v.Day, 0, 0, 0, 0, time.Local))
|
||||||
|
if lmonth > v.Month {
|
||||||
|
lyear--
|
||||||
|
}
|
||||||
|
fmt.Println(lyear, desp, v.Year, v.Month, v.Day)
|
||||||
|
if lyear != v.Lyear || lmonth != v.Lmonth || lday != v.Lday || leap != v.Leap {
|
||||||
|
t.Fatal(v, lyear, lmonth, lday, leap, desp)
|
||||||
|
}
|
||||||
|
|
||||||
|
date := RapidLunarToSolar(v.Lyear, v.Lmonth, v.Lday, v.Leap)
|
||||||
|
if date.Year() != v.Year || int(date.Month()) != v.Month || date.Day() != v.Day {
|
||||||
|
t.Fatal(v, date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user