[Remind-Fans] Chinese lunisolar calendar

Tim Chase remind at tim.thechases.com
Fri Dec 29 09:51:16 EST 2023


On 2023-12-29 09:19, Remind list wrote:
> Is there any reasonable way to encode the Chinese solar terms?
>
>     https://en.wikipedia.org/wiki/Solar_term

I'm not sure if there's a better way, but I pulled together the
code below which should get pretty close.  According to that Wikipedia
article, 0-degrees starts on Mar 21st, but it seems to me that it
should be at the vernal equinox, so if you want to switch, you can
comment/uncomment the corresponding two lines.  I don't know if
things should switch if you go from the northern hemisphere to the
southern (I know I have code to switch vernal/autumnal equinoxes
based on $Lat)

The below determines which month each day-of-the-year is in, not
the first day of that month (for which you'd have to check if the
previous day's month-name differs from the current month-name; there
might be a more efficient way to determine the start-of-month days).

It should be (fairly) mathematically precise, but some of the
transition-dates don't line up quite exactly with the dates on that
Wikipedia article, off by a day in one direction or the other.  I
couldn't determine from the article why they differed from the
mathematical division of the year.

Anyways, this might prove a useful starting point for any modifications
you want to make.

-tim


FSET julian(dt) \
	1 + ( \
	date(year(dt), monnum(dt), day(dt)) \
	- date(year(dt), 1, 1) \
	)

# choose one of thse two definitions:
# per Wikipedia, this is Mar 21
FSET zero_deg(dt) julian(date(year(dt), 3, 21))
# but it seems like the 0° date should be the spring equinox
#FSET zero_deg(dt) julian(soleq(0, dt))

FSET days_in_yr(dt) isleap(dt) + 365
FSET solar_angle(dt) ( \
	((days_in_yr(dt) + julian(dt) - zero_deg(dt)) % days_in_yr(dt))) * 360 / days_in_yr(dt)

FSET angle_to_st(dt) choose(1+(solar_angle(dt) / 15) \
	, "chūnfēn" \
	, "qīngmíng" \
	, "gǔyǔ" \
	, "lìxià" \
	, "xiÇŽomÇŽn" \
	, "mángzhòng" \
	, "xiàzhì" \
	, "xiÇŽoshÇ”" \
	, "dàshǔ" \
	, "lìqiū" \
	, "chǔshǔ" \
	, "báilù" \
	, "qiūfēn" \
	, "hánlù" \
	, "shuāngjiàng" \
	, "lìdōng" \
	, "xiÇŽoxuÄ›" \
	, "dàxuě" \
	, "dōngzhì" \
	, "xiǎohán" \
	, "dàhán" \
	, "lìchūn" \
	, "yǔshuǐ" \
	, "jīngzhé" \
	)

REM MSG Solar term: [angle_to_st($T)]







More information about the Remind-fans mailing list