feat(calendar): make Mayan new year start and seven-year anchor configurable - #72
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
lifeos-cli #331 的 Web 配套:玛雅 13 月亮历的「新年开始日」(MM-DD,默认 07-26)与「七年锚点年份」改为用户偏好。设置页新增新年开始日输入(前一天为无时间日),七年锚点由「完整日期」改为「年份」输入;2/29 按 2/28 处理。前端
MayanCalendarAdapter与useCalendarAdapter同步读取新偏好。Related lifeos-plus/lifeos-cli#330, lifeos-plus/lifeos-cli#331
改动
src/utils/calendar/CalendarAdapter.ts:DEFAULT_SEVEN_YEAR_ANCHOR_DATE拆为DEFAULT_SEVEN_YEAR_ANCHOR_YEAR(2025)+DEFAULT_MAYAN_NEW_YEAR_START(07-26),新增parseMayanNewYearStart/normalizeMayanNewYearStart(02-29→02-28)。src/utils/calendar/MayanCalendarAdapter.ts:构造参数改为sevenYearAnchorYear+mayanNewYearStart;getMayanYearStart使用配置的月-日;2/29 输入归一化为 2/28;七年锚点从「锚点年 + 新年开始日」计算。src/utils/calendar/GregorianCalendarAdapter.ts:七年锚点改收年份。src/hooks/useCalendarAdapter.ts:读取calendar.seven_year_anchor_year与calendar.mayan_new_year_start。src/config/settingsConfig.tsx/src/pages/SettingsPage.tsx:七年起始日期(date)替换为七年锚点年份(number);玛雅历下新增新年开始日(MM-DD,custom 组件MayanNewYearStartPreference)。sevenYearAnchorDate→sevenYearAnchorYear,新增mayanNewYearStart,系统描述改为「新年开始日可配置」。审查与加固
第一轮(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)。getDisplayYear的month === 7 && day === 26快路径:改为「storedDate 等于配置的新年开始日」判断,自定义新年(尤其 S>07-26,如 12-31)下不再返回错误年份。getDateForYearSelection硬编码new Date(year, 6, 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)与七年锚点年份;切换历法后立即生效。