feat(calendar): make Mayan new year start and seven-year anchor user-configurable - #331
Merged
Merged
Conversation
…configurable The Mayan 13 Moon new year start (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 so the 13-moon year stays fixed at 365 days. - config: add calendar_mayan_new_year_start (MM-DD) and calendar_seven_year_anchor_year; migrate the legacy full-date anchor - adapter: thread both preferences through get_calendar_adapter, get_calendar_period_range, iter_calendar_periods and the Mayan adapter - stats: derive excluded week/month dates from preferences - web: expose the new preference keys and task meta fields - tests: custom new year, leap-day normalization, and stats exclusion
This was referenced Aug 26, 2026
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
把玛雅 13 月亮历的「新年开始日」从硬编码 07-26(无时间日 07-25)扩展为用户偏好:
/config设置页可把任意公历「月-日」设为新年开始(默认 07-26),此日的前一天为无时间日;七年周期锚点改为精确到「年」。所有消费新年 / 无时间日 / 七年周期的路径统一经MayanCalendarAdapter获取,不再各处重复实现。2/29 自动按 2/28 处理,13 月亮年固定为 365 天。Closes #330
背景与决策
MayanCalendarAdapter.year_start()硬编码 07-26;is_mayan_day_out_of_time()硬编码 7 月 25 日;七年锚点为完整日期calendar_seven_year_anchor_date(YYYY-MM-DD)。calendar_mayan_new_year_start(MM-DD,默认07-26)+calendar_seven_year_anchor_year(YYYY,默认 2025)。calendar_seven_year_anchor_date仅迁移「年份」到calendar_seven_year_anchor_year;其月-日部分不再使用(新年开始日由独立偏好决定,默认 07-26),配置文件在下次写入时自动落盘新键。改动
src/lifeos_cli/config.py:新增两个偏好字段与校验器(含 02-29→02-28 归一化)、序列化与旧字段迁移。src/lifeos_cli/application/calendar_adapter.py:MayanCalendarAdapter持有new_year_start与seven_year_anchor_year;DOOT 判定收敛为 adapter 方法;get_calendar_adapter/get_calendar_period_range/iter_calendar_periods改为接收新偏好参数。src/lifeos_cli/db/services/timelog_stats.py:周/月统计排除日期改为按偏好推导(含闰日双日期排除)。src/lifeos_cli/db/services/task_queries.py、src/lifeos_web/routers/stats.py、src/lifeos_web/routers/tasks.py、src/lifeos_web/response_schemas/tasks.py:消费侧改传新偏好;任务列表 meta 由seven_year_anchor_date改为seven_year_anchor_year+mayan_new_year_start。src/lifeos_web/routers/preferences.py:API 键映射与元数据更新。tests/config_support.py支持写入新偏好。契约影响
GET /api/v1/preferences:移除calendar.seven_year_anchor_date,新增calendar.mayan_new_year_start与calendar.seven_year_anchor_year。GET /api/v1/tasksmeta:seven_year_anchor_date→seven_year_anchor_year+mayan_new_year_start。MayanCalendarAdapter同步)。审查与验证
bash ./scripts/doctor.sh全绿:lint / ruff format / dead-code / mypy / 913 tests(覆盖率 ≥74%)/ 依赖审计 / 构建通过;PostgreSQL 集成按环境跳过。Related #329 #192 #324 lifeos-plus/lifeos-web#72