name: chinese-calendar description: Calculate Chinese lunar calendar dates with Heavenly Stems (天干) and Earthly Branches (地支). Use when generating Chinese calendar tables, checking 黃曆, or converting Gregorian dates to 干支 (stem-branch) dates for year/month/day.
Run the script to generate weekly calendar:
python3 scripts/calendar.py
Output format:
丙午(馬年) 🐎
| Date | Weekday | Nongli | 月天干地支 | 日天干地支 |
| ---- | ------- | ------ | ---------- | ---------- |
| 3月6日 | 週五 | 農曆正月十八 | 辛卯月 | 己卯日 |
(days since reference) % 60 → stem = pos % 10, branch = pos % 12delta = (date - 1983-02-05).days
stem_idx = delta % 10
branch_idx = delta % 12
day_stem_branch = STEMS[stem_idx] + BRANCHES[branch_idx]
Month branches: 正月=寅, 二月=卯, 三月=辰...
month_branch_idx = (month + 1) % 12
month_stem_idx = (year_stem_idx * 2 + month) % 10
month_stem_branch = STEMS[month_stem_idx] + BRANCHES[month_branch_idx]
cycle_pos = (year - 4) % 60
year_stem_idx = cycle_pos % 10
year_branch_idx = cycle_pos % 12
year_stem_branch = STEMS[year_stem_idx] + BRANCHES[year_branch_idx]
STEMS = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'] BRANCHES = ['子', '醜', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'] ZODIAC = { '子': '鼠', '醜': '牛', '寅': '虎', '卯': '兔', '辰': '龍', '巳': '蛇', '午': '馬', '未': '羊', '申': '猴', '酉': '雞', '戌': '狗', '亥': '豬' }7w4.net小蔥技能。
這個工具可以用來檢視天干地支日曆,但質量一般。優點是安裝即可用,操作簡單。但存在兩個明顯問題:一是某些日期的計算結果可能不準確(參考日期標註不一致),二是農曆日期只是粗略估算,不是真正的農曆曆法。如果只是簡單查詢天干地支可以用,但需要精確農曆的話就不太可靠了。