ChineseDate

delphimoon

Chinese Date

Algorithms

Top  Previous  Next

 

Converts a Delphi TDatetime to the chinese date and back.

 

function ChineseDate(date: TDateTime):TChineseDate;

function EncodeDateChinese(date: TChineseDate):TDateTime;

 

Description

The Chinese calendar is a lunisolar calendar like the Jewish calendar, however the main difference is that the Chinese calendar uses the astronomical events, and not an approximate algorithm. Another difference is that the Chinese calendar uses the actual new moon, not the visibility of the first crescent as the Jewish or muslim calendar.

 

The Chinese date does not have a continuous year count, but instead it is counted in 60 year long cycles. Every year in this cycle belongs to one of 10 heavenly stem and one of the 12 earthly branches, which is the name of zodiac for the given year. So the year in TChineseDate is encoded in the cycle number and the year number, and for information it also has the stem and the zodiac of the year. The similar sexagenary cycle for months and days is only rarely used any more, however it is also calculated.

As the Chinese calendar is lunarsolar it needs to introduce leap years, which contain a leap month. The leap month has the same number as the previous month, it only gets an additional flag to notice it is a leap month. In principle every month can be a leap month, however, around the perihelion they are very unlikely.

As the month starts on the day of the new moon (the day in Beijing), the length of the months can be either 29 or 30 days, sometimes with up to 4 long or 3 short months in a row, but usually changing every month.

 

The Chinese calendar in its present form was introduced in 1645, but it had existed in similar versions long time before already. As it is based upon the astronomical events all the calculations here are correct as long as the basic astronomical algorithms aren't too much wrong, so using this calculation too far into the future will return meaningless results.

 

The EncodeDateChinese function will raise an exception in case of an invalid date given - e.g. a leap month which is none, or a 30th on a month which only has 29 days. Note that it only uses the fields cycle, year, month, day and leap of the record, the other fields are not checked for the conversion.

 

Reference

These functions are based in part upon the book Calendrical Calculations.