Skip to content

feat(calendar): make Mayan new year start and seven-year anchor configurable - #72

Merged
liujuanjuan1984 merged 5 commits into
mainfrom
feat/mayan-new-year-configurable
Aug 26, 2026
Merged

feat(calendar): make Mayan new year start and seven-year anchor configurable#72
liujuanjuan1984 merged 5 commits into
mainfrom
feat/mayan-new-year-configurable

Conversation

@liujuanjuan1984

@liujuanjuan1984 liujuanjuan1984 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

TL;DR

lifeos-cli #331 的 Web 配套:玛雅 13 月亮历的「新年开始日」(MM-DD,默认 07-26)与「七年锚点年份」改为用户偏好。设置页新增新年开始日输入(前一天为无时间日),七年锚点由「完整日期」改为「年份」输入;2/29 按 2/28 处理。前端 MayanCalendarAdapteruseCalendarAdapter 同步读取新偏好。

Related lifeos-plus/lifeos-cli#330, lifeos-plus/lifeos-cli#331

改动

  • src/utils/calendar/CalendarAdapter.tsDEFAULT_SEVEN_YEAR_ANCHOR_DATE 拆为 DEFAULT_SEVEN_YEAR_ANCHOR_YEAR(2025)+ DEFAULT_MAYAN_NEW_YEAR_START07-26),新增 parseMayanNewYearStart / normalizeMayanNewYearStart(02-29→02-28)。
  • src/utils/calendar/MayanCalendarAdapter.ts:构造参数改为 sevenYearAnchorYear + mayanNewYearStartgetMayanYearStart 使用配置的月-日;2/29 输入归一化为 2/28;七年锚点从「锚点年 + 新年开始日」计算。
  • src/utils/calendar/GregorianCalendarAdapter.ts:七年锚点改收年份。
  • src/hooks/useCalendarAdapter.ts:读取 calendar.seven_year_anchor_yearcalendar.mayan_new_year_start
  • src/config/settingsConfig.tsx / src/pages/SettingsPage.tsx:七年起始日期(date)替换为七年锚点年份(number);玛雅历下新增新年开始日(MM-DD,custom 组件 MayanNewYearStartPreference)。
  • 文案:en/zh 的 sevenYearAnchorDatesevenYearAnchorYear,新增 mayanNewYearStart,系统描述改为「新年开始日可配置」。
  • 测试:自定义新年(03-01)、2/29 归一化、七年锚点年、设置项结构断言更新。

审查与加固

第一轮(commit cc5cf3f):

  • 输入 02-29 时输入框 draft 与提交值不一致(现在显示与保存均为归一化后的 02-28);normalizeMayanNewYearStart 复用单一月-日解析器,消除重复实现;补充解析/归一化单测。

第二轮(commit 0578497)——7/25、7/26 残留排查:

  • buildYearGroups 的「无时间日」节点日期硬编码 new Date(year+1, 6, 25):自定义新年下会把 DOOT 节点错误放在 7 月 25 日。已改为新增的 getDayOutOfTime(yearStart)(与后端语义一致,02-29→02-28)。
  • getDisplayYearmonth === 7 && day === 26 快路径:改为「storedDate 等于配置的新年开始日」判断,自定义新年(尤其 S>07-26,如 12-31)下不再返回错误年份。
  • getDateForYearSelection 硬编码 new Date(year, 6, 26):改为配置的新年开始日,规划周期「年份选择」在自定义新年下生成正确起始日。
  • 同步更新两处过时注释(“July 26 / July 25”)并补充对应测试。
  • 全仓复查结论:剩余 7/25、7/26 引用仅为默认常量、默认值文案与测试断言,无其它硬编码业务逻辑。

契约与验证

  • scripts/pinned-cli-version.mjs 升至 v1.3.5,api:refresh 拉取 v1.3.5 release 的 OpenAPI 契约(含完整性 pin)并重新生成 schema.ts(任务列表 meta 由 seven_year_anchor_date 更新为 seven_year_anchor_year + mayan_new_year_start,与后端 #331 一致);api:check 通过。
  • npm run lint(0 warnings)、npm run build(tsc + vite)、npm run test(476 passed)全部通过。

验收标准

  • /config 设置页可配置玛雅新年开始日(默认 07-26)与七年锚点年份;切换历法后立即生效。
  • 无时间日 = 新年开始日的前一天(2/29 场景按 2/28 处理),不出现在周/月导航、年份视图与 insights 桶中。

…gurable

Mirror the lifeos-cli preference model in the Web UI: the Mayan new year
start (MM-DD, default 07-26) and the seven-year anchor year are now user
preferences instead of hardcoded constants. The Day Out of Time is the day
before the configured new year start; February 29 is treated as February 28.

- adapter: MayanCalendarAdapter accepts mayanNewYearStart and
  sevenYearAnchorYear; Gregorian adapter takes the anchor year
- hooks: useCalendarAdapter reads calendar.mayan_new_year_start and
  calendar.seven_year_anchor_year
- settings: replace seven-year start date control with an anchor year
  input and add a Mayan new year start (MM-DD) control
- locales: update en/zh calendar copy
- tests: custom new year start, February 29 normalization, anchor year
…tart

Typing 02-29 now displays the normalized 02-28 value instead of leaving
the draft inconsistent with the committed preference, and the normalizer
reuses the single month-day parser.
…rom configured new year start

The year-group Day Out of Time node, display-year fast path, and year
selection date still hardcoded July 25/26, so a custom new year start
produced wrong dates in the planning year view and year picker. All three
now derive from the configured month-day, matching the backend semantics;
February 29 stays normalized to February 28.
Consume the v1.3.5 release contract, which replaces the task-list meta
seven_year_anchor_date field with seven_year_anchor_year plus
mayan_new_year_start to match the configurable Mayan new year start.
…rage

The Validate Frontend CI failed its 70% added-line coverage gate. Add
component tests for MayanNewYearStartPreference, a SettingsPage test that
saves the anchor year and new year start through the real preference
hook, adapter fallback tests for invalid preference values, and a render
invocation for the new settings item.
@liujuanjuan1984
liujuanjuan1984 merged commit 76b355f into main Aug 26, 2026
1 check passed
@liujuanjuan1984
liujuanjuan1984 deleted the feat/mayan-new-year-configurable branch August 26, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant