calendar: 补齐前104古历纪年解析与回归测试

- 为先秦与秦汉古历结果填充周、鲁、秦、西汉早期纪年信息
- 支持默认与显式古历下的年号日期解析
This commit is contained in:
2026-06-11 09:33:46 +08:00
parent a8e7513683
commit 25dc7ac0bc
7 changed files with 373 additions and 7 deletions
+12 -5
View File
@@ -328,7 +328,7 @@ func (l LunarTime) innerDescWithNianHao(withEmperor bool, withDynasty bool) []st
res = append(res, tmp)
}
} else {
res = append(res, number2Chinese(l.year, true)+"年"+l.desc)
res = append(res, lunarYearDesc(l.year)+"年"+l.desc)
}
return res
}
@@ -343,7 +343,7 @@ func (l LunarTime) LunarInfo() []LunarInfo {
li := LunarInfo{
SolarDate: l.solarDate,
LunarYear: l.year,
LunarYearChn: number2Chinese(l.year, true),
LunarYearChn: lunarYearDesc(l.year),
LunarMonth: l.month,
LunarDay: l.day,
IsLeap: l.leap,
@@ -367,7 +367,7 @@ func (l LunarTime) LunarInfo() []LunarInfo {
li := LunarInfo{
SolarDate: l.solarDate,
LunarYear: l.year,
LunarYearChn: number2Chinese(l.year, true),
LunarYearChn: lunarYearDesc(l.year),
LunarMonth: l.month,
LunarDay: l.day,
IsLeap: l.leap,
@@ -381,11 +381,18 @@ func (l LunarTime) LunarInfo() []LunarInfo {
Emperor: "",
Nianhao: "",
YearOfNianhao: 0,
EraDesc: number2Chinese(l.year, true) + "年",
LunarWithEraDesc: number2Chinese(l.year, true) + "年" + l.desc,
EraDesc: lunarYearDesc(l.year) + "年",
LunarWithEraDesc: lunarYearDesc(l.year) + "年" + l.desc,
ChineseZodiac: l.ShengXiao(),
}
res = append(res, li)
}
return res
}
func lunarYearDesc(year int) string {
if year <= 0 {
return "前" + number2Chinese(1-year, true)
}
return number2Chinese(year, true)
}