• feat(calendar): 扩展先秦至秦汉古历支持

- 新增显式古历 API,支持先秦古历与秦汉颛顼历选择
- 将默认公农历转换范围扩展至 -721..3000
- 支持后九月解析、负年份干支日和古历法相符节气
- 补充秦汉、先秦、交接边界和节气回归测试
This commit is contained in:
2026-06-09 19:35:18 +08:00
parent c8dd777a7b
commit a8e7513683
9 changed files with 1985 additions and 52 deletions
+24
View File
@@ -28,6 +28,10 @@ type LunarInfo struct {
GanzhiMonth string `json:"ganzhiMonth"`
// GanzhiDay 农历日干支
GanzhiDay string `json:"ganzhiDay"`
// CalendarSystem 历法系统
CalendarSystem AncientCalendarSystem `json:"calendarSystem"`
// CalendarName 历法名称
CalendarName string `json:"calendarName"`
// Dynasty 朝代,如唐、宋、元、明、清等
Dynasty string `json:"dynasty"`
// Emperor 皇帝姓名(仅供参考,多个皇帝用同一个年号的场景,此处不准)
@@ -190,6 +194,12 @@ type LunarTime struct {
comment string
//ganzhi of month 月干支
ganzhiMonth string
//后九月
houMonth bool
//历法系统
calendarSystem AncientCalendarSystem
//历法名称
calendarName string
eras []EraDesc
}
@@ -244,6 +254,16 @@ func (l LunarTime) IsLeap() bool {
return l.leap
}
// CalendarSystem 历法系统 / calendar system.
func (l LunarTime) CalendarSystem() AncientCalendarSystem {
return l.calendarSystem
}
// CalendarName 历法名称 / calendar name.
func (l LunarTime) CalendarName() string {
return l.calendarName
}
// Eras 朝代、皇帝、年号信息 / era information.
//
// 返回该农历结果对应的朝代、皇帝、年号信息。
@@ -331,6 +351,8 @@ func (l LunarTime) LunarInfo() []LunarInfo {
GanzhiYear: GanZhiOfYear(l.year),
GanzhiMonth: l.ganzhiMonth,
GanzhiDay: GanZhiOfDay(l.solarDate),
CalendarSystem: l.calendarSystem,
CalendarName: l.calendarName,
Dynasty: v.Dynasty,
Emperor: v.Emperor,
Nianhao: v.Nianhao,
@@ -353,6 +375,8 @@ func (l LunarTime) LunarInfo() []LunarInfo {
GanzhiYear: GanZhiOfYear(l.year),
GanzhiMonth: l.ganzhiMonth,
GanzhiDay: GanZhiOfDay(l.solarDate),
CalendarSystem: l.calendarSystem,
CalendarName: l.calendarName,
Dynasty: "",
Emperor: "",
Nianhao: "",