Glich - v0.3.0 Manual
c - The lunisolar Chinese calendar
Home Development v0.3.0 Manual Hics Library c

Calendar Description - Scheme c

The Chinese calendar is a lunisolar calendar with 12 lunar months in a common year and 13 in a leap year. The start of the year occurs just before the Northward/Spring equinox and is tied to the Southern/Winter solstice. Months start on the day of the new moon and have 39 or 30 days.

Use Case

Definition

Record - Default Order
yearmonthlmonthday cycle cyear clmonth stem branch

The Record consists of four Fields named year, month, lmonth, and day. There are twelve common months in a year numbered 1 to 12. The lmonth field is set to 0 for these months. In a leap year, one of the months will be repeated with the lmonth field set to 1. Each month starts on day 1, the day of the new moon, and will be 29 or 30 days long.

The Epoch is set at
cyearmonthlmonthday
1101
=
gyearmonthday
-2636215
=
jdnday
758326
.

The calculated cycle field counts the number of 60 year cycles since the year -2636 Gregorian. The calculated cyear field is the year within the cycle.

The other calculated fields clmonth, stem and branch are used for formatting.

Formats

Branch Names - Lexicons cbrch & animal
ValueNameAbbrev.Animal
1ZiRat
2ChǒuChouOx
3YínYinTiger
4MǎoMaoRabbit
5ChénChenDragon
6SiSnake
7WuHorse
8WèiWeiGoat
9ShēnShenMonkey
10YǒuYouRooster
11XuDog
12HàiHaiPig
Stem Names - Lexicon cstem
ValueNameAbbrev.
1JiǎJia
2Yi
3BǐngBing
4DīngDing
5Wu
6Ji
7GēngGeng
8XīnXin
9RénRen
10GuìGui
Leap Month Names - Lexicon lmon
ValueNameAbbrev.
0MonthMonth
1Leap-monthLeap
First or Second Names - Lexicon fs
ValueNameAbbrev.
0FirstF
1SecondS

The lmonth field only needs to be displayed when there are a leap month pair, for other months it is redundant. The calculated clmonth field is a copy of the lmonth when one of a leap month pair and a null value otherwise.

The formats supplied with this scheme.

Formats - Grammar c
CodeRulePseudo / ExampleNote
ymldtextInput: year month lmonth day
Output: yy mm FS dd
S
4662 6 F 15
4662 6 S 15
4662 7 F 15
ylmdtextInput: year lmonth month day
Output: yy LM mm dd
S
4662 Month 6 15
4662 Leap 6 15
4662 Month 7 15
cymldtextInput: cycle cyear month lmonth day
Output: cc cy mm fs dd
D, S
78 42 6 f 15
78 42 6 s 15
78 42 7 f 15
cylmdtextInput: cycle cyear clmonth month day
Output: cc cy LM mm dd
78 42 6 15
78 42 Leap 6 15
78 42 7 15
cylmd_stextInput: cycle stem branch clmonth month day
Output: cc Stem-branch, LM mm dd
78 Yǐ-sì 6 15
78 Yǐ-sì, Leap 6 15
78 Yǐ-sì 7 15
fulltextOutput: Cycle: cc, Year: Stem-branch (cy), LeapMon: mm, Day: dd
Cycle: 78, Year: Yǐ-sì (42), Month: 6, Day: 15
Cycle: 78, Year: Yǐ-sì (42), Leap-month: 6, Day: 15
Cycle: 78, Year: Yǐ-sì (42), Month: 7, Day: 15
animaltextOutput: (Cycle cc) Year of the Animal cy LeapMon mm Day dd
(Cycle 78) Year of the Snake 42 Month 6 Day 15
(Cycle 78) Year of the Snake 42 Leap-month 6 Day 15
(Cycle 78) Year of the Snake 42 Month 7 Day 15
deftextInput: year month lmonth day cycle cyear clmonth stem branch
Output: yy mm lm dd cc cy cm ss bb
H
4662 6 0 15 78 42 2 6
4662 6 1 15 78 42 1 2 6
4662 7 0 15 78 42 2 6
uunitInput: 9year 9m 9lm 9d 9c 9y 9cm 9s 9b
Output: 9year 9m 9lm 9d 9c 9y 9cm 9s 9b
H
4662year 6m 0lm 15d 78c 42y 2s 6b
4662year 6m 1lm 15d 78c 42y 1cm 2s 6b
4662year 7m 0lm 15d 78c 42y 2s 6b
Notes: D = Default, H = Hidden. Example based on jdn# 2460866, 2460896 and 2460925

Script

Default Script
lexicon cstem { name "Chinese Stem"; fieldname stem; lang en; pseudo Stem, Stm; tokens { 1, "Jiǎ", "Jia"; 2, "Yǐ", "Yi"; 3, "Bǐng", "Bing"; 4, "Dīng", "Ding"; 5, "Wù", "Wu"; 6, "Jǐ", "Ji"; 7, "Gēng", "Geng"; 8, "Xīn", "Xin"; 9, "Rén", "Ren"; 10, "Guì", "Gui"; }; }; lexicon cbrch { name "Chinese Branch"; fieldname branch; lang en; pseudo branch, brch; tokens { 1, "Zǐ", "Zi"; 2, "Chǒu", "Chou"; 3, "Yín", "Yin"; 4, "Mǎo", "Mao"; 5, "Chén", "Chen"; 6, "Sì", "Si"; 7, "Wǔ", "Wu"; 8, "Wèi", "Wei"; 9, "Shēn", "Shen"; 10, "Yǒu", "You"; 11, "Xū", "Xu"; 12, "Hài", "Hai"; }; }; lexicon animal { name "Chinese Year Animals"; fieldname branch; lang en; pseudo Animal; tokens { 1, "Rat"; 2, "Ox"; 3, "Tiger"; 4, "Rabbit"; 5, "Dragon"; 6, "Snake"; 7, "Horse"; 8, "Goat"; 9, "Monkey"; 10, "Rooster"; 11, "Dog"; 12, "Pig"; }; }; lexicon lmon { name "Leap month"; fieldname clmonth; lang en; pseudo LeapMon, LM; tokens { 0, "Month"; 1, "Leap-month", "Leap"; }; }; lexicon fs { name "First and Second"; fieldname lmonth; lang en; pseudo FirstSecond, FS; tokens { 0, "First", "F"; 1, "Second", "S"; }; }; grammar c { fields year month lmonth day; calculated cycle cyear clmonth stem branch; // Record: year month lmonth day cycle cyear clmonth stem branch lexicons lmon fs cstem cbrch animal; alias pseudo { yy year; mm month; lm lmonth; cm clmonth; dd day; cc cycle; cy cyear; ss stem; bb branch; }; alias unit { d day; m month; lm lmonth; y cyear; c cycle; cm clmonth; s stem; b branch; }; function calculate { cycle = ( (year - 1) div 60 ) + 1; cyear = ( (year - 1) mod 60 ) + 1; stem = (cyear - 1) mod 10 + 1; branch = (cyear - 1) mod 12 + 1; clmonth = @if(lmonth=0, null, 1); result = this; }; function fixed { // format cymld if stem <> null and branch <> null { cyear = ((stem - branch) mod 12) * 5 + stem; }; if cycle <> null and cyear <> null { year = (cycle - 1) * 60 + cyear; }; clmonth = @if(lmonth=0, null, 1); stem = (cyear - 1) mod 10 + 1; branch = (cyear - 1) mod 12 + 1; result = this; }; function cycle_to_year { // format cylmd if stem <> null and branch <> null { cyear = ((stem - branch) mod 12) * 5 + stem; }; if cycle <> null and cyear <> null { year = (cycle - 1) * 60 + cyear; }; lmonth = @if( clmonth = null, 0, clmonth ); clmonth = @if(lmonth=0, null, 1); stem = (cyear - 1) mod 10 + 1; branch = (cyear - 1) mod 12 + 1; result = this; }; format ymld "{year}| {month}| {lmonth:fs:a}| {day}"; format ylmd "{year}| {lmonth:lmon:a}| {month}| {day}"; // Note, format used in "Calendrical Calculations" format cymld { inout "{cycle}| {cyear}| {month}| {lmonth:fs:a:l}| {day}"; rank cycle cyear month lmonth day; }; format cylmd { inout "{cycle}| {cyear}| {clmonth:lmon*:a}| {month}| {day}"; rank cycle cyear month day lmonth; use:in cycle_to_year; }; format cylmd_s { inout "{cycle}| {stem:cstem}|-{branch:cbrch::l}|, {clmonth:lmon:a}| {month}| {day}"; rank cycle month day; separators ",-"; use:in cycle_to_year; }; format full { output "Cycle: {cycle},| Year: {stem:cstem}-{branch:cbrch::l} ({cyear}),| {lmonth:lmon}:| {month},| Day: {day}"; }; format animal { output "(Cycle {cycle})| Year of the {branch:animal} {cyear}| {lmonth:lmon}| {month}| Day {day}"; }; preferred cymld; }; scheme c { name "Chinese"; base chinese; grammar c; };

The script is not dependent on any other script at this time

Home Development v0.3.0 Manual Hics Library c

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

1st July 2024