bug fix:解决非东八区的农历计算不正确的问题

This commit is contained in:
2023-07-23 11:47:36 +08:00
parent ebdcf65c46
commit 6b97736829
4 changed files with 32 additions and 30 deletions
+4 -4
View File
@@ -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)
}