-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalendarSolarLabels.ts
More file actions
43 lines (38 loc) · 1.52 KB
/
Copy pathcalendarSolarLabels.ts
File metadata and controls
43 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* 公历节日与调休展示(与 2026 春学期演示一致,可按年扩展)
* key: "YYYY-M-D"(月、日无前导零也可在 lookup 时规范化)
*/
export type SolarCellExtra = {
/** 格内主副标题下方优先展示的公历节日名 */
holiday?: string;
/** 在日期数字旁显示绿色「休」 */
rest?: boolean;
};
const RAW: Record<string, SolarCellExtra> = {
'2026-3-3': { holiday: '元宵节' },
'2026-3-8': { holiday: '妇女节' },
'2026-3-12': { holiday: '植树节' },
'2026-4-4': { holiday: '清明节', rest: true },
};
export function getSolarExtra(y: number, m0: number, d: number): SolarCellExtra | undefined {
const key = `${y}-${m0 + 1}-${d}`;
return RAW[key];
}
const LUNAR_NAMES = [
'初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十',
'十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十',
'廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十',
] as const;
/** 2026 年 3 月:3 月 1 日对应农历十三(与 3 月 29 日为「十一」一致) */
export function getLunarSubline(y: number, m0: number, day: number): string {
if (y === 2026 && m0 === 2) {
const idx = (12 + (day - 1)) % 30;
return LUNAR_NAMES[idx];
}
if (y === 2026 && m0 === 3 && day >= 1) {
const idx = (12 + 31 + (day - 1)) % 30;
return LUNAR_NAMES[idx];
}
const seed = (y * 372 + (m0 + 1) * 31 + day) % 30;
return LUNAR_NAMES[seed];
}