(* :Name: ChineseCalendar.m *) (* :Context: ChineseCalendar` *) (* :Title: Chinese Calendar Computations *) (* :Author: Helmer Aslaksen Department of Mathematics National University of Singapore Singapore 117543 Singapore helmer.aslaksen@gmail.com http://www.math.nus.edu.sg/aslaksen/ *) (* :Mathematica Version: 8.0 *) (* :Package Version: 1.07, 2011 June 3 *) (* :History: 1.0, 1999 June 8 First version. 1.01, 1999 June 11 m* and t* functions added. timeToLiChun added. 1.02, 1999 July 12 majorSolarTermsInYear bug fixed. Missed z1 if it coincided with Chinese New Year. 1.03, 1999 July 16 Redefined MinorSolarTermsInYear to fix bug in the code of Dershowitz and Reingold. 1.04, 1999 Sep. 22 lengthOfChineseYear added. lengthOfChineseYearsBetween added. 1.05, 1999 Oct. 6 lengthOfChineseMonthsBetween added. stringsOfChineseMonthsBetween added. 1.06, 1999 Oct. 23 chineseFullMoonAfter added. timeOfChineseFullMoonAfter added. dayOfChineseFullMoonBetween added. solsticeYear added. winterSolsticeOnOrBefore added. fakeLeapMonthsBetween added. twoZhongQisBetween added. twoJieQisBetween added. liChunErrorBetween added. lateLiChunBetween added. z12ErrorBetween added. BarChart added to chineseLeapMonthsBetween. Name changed from ChineseLeapMonths to ChineseCalendar. 1.07, May 30, 2011 Updated CalendricaV1.m to Mathematica V8 (http://www.math.nus.edu.sg/aslaksen/calendar/CalendricaV1.m) by changing Full[] to FullMoon[] and DateDifference[] to GregorianDateDifference[]. BarChart became a built-in Mathematica symbol in V7. Changed BarOrientation->Horizontal to BarOrigin->Left. Changed BarLabels to ChartLabels. 2.0, 2011 June 3 Updated Calendrica V2. Changed usage for MajorSolarTermOnOrAfter to say moment instead of fixed date. Use Calendrica V2. Changed Calendrica`Private to Calendrica`. Gregorian[Y,M,D] instead of Gregorian[M,D,Y]. Gregorian and ChineseNewMoonOnOrAfter take integer values, so I must use Floor. Solar term functions are moments, so some m* functions are no longer needed and I must use Floor on the output in some cases. Use moment instead of JD. Use locale instead ChineseTimeZone. *) (* :Keywords: Chinese calendar, calendar, leap months, intercalation, Chinese New Year *) (* :Summary: ChineseCalendar is a package for performing Chinese calendrical computations. It is written by Helmer Aslaksen, Department of Mathematics, National University of Singapore, helmer.aslaksen@gmail.com, http://www.math.nus.edu.sg/aslaksen/. It uses the functions written by Nachum Dershowitz and Edward M. Reingold for their book Calendrical Calculations. Their Lisp functions were translated into the Mathematica package Calendrica by Robert C. McNally , and modified by me. They are available from http://www.math.nus.edu.sg/aslaksen/calendar/Calendrica.m . *) (* :Warnings: The names of my functions have lower case initials to distinguish them from the functions of Robert C. McNally. I describe Chinese months by {gYear, cMonth}. I number a Chinese year by the Gregorian year in which it starts. So {1999,12} starts on January 7, 2000. *) (* Solar terms and new moons are given by dates, so I need m* functions for these. *) (* :Copyright: Copyright 1999-2011, Helmer Aslaksen *) (************** START OF PUBLIC CODE **************) BeginPackage["ChineseCalendar`",{"Calendrica`"}] Needs["Calendrica`"] ChineseCalendar::usage="ChineseCalendar is a package for performing Chinese calendrical computations. It is written by Helmer Aslaksen, Department of Mathematics, National University of Singapore, helmer.aslaksen@gmail.com, http://www.math.nus.edu.sg/aslaksen/. It uses the functions written by Nachum Dershowitz and Edward M. Reingold for their book Calendrical Calculations. Their Lisp functions were translated into the Mathematica package Calendrica by Robert C. McNally , and updated for Mathematica V8 by me. They are available from http://www.math.nus.edu.sg/aslaksen/calendar/Calendrica.m ."; nthChineseNewMoonOnOrAfterChineseNewYear::usage= "nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n] gives the fixed date for the nth new moon on or after Chinese New Year in the given Gregorian year."; nthChineseMonth::usage="nthChineseMonth[gYear, n, leap] gives the Gregorian date for the new moon that starts the nth Chinese month in the Chinese year that starts in the given Gregorian year. If it is a leap month, add an extra variable equal to 1."; chineseNewMoonsInYear::usage="chineseNewMoonsInYear[gYear] lists the Gregorian dates of the new moons in the Chinese year starting in the given Gregorian year."; majorSolarTermsInYear::usage="majorSolarTermsInYear[gYear] lists the Gregorian dates of the major solar terms (zhong qi's) in the Chinese year starting in the given Gregorian year."; chineseLeapYearQ::usage="chineseLeapYearQ[gYear] returns True if the Chinese year starting in the given Gregorian year is a leap year."; chineseLeapSolsticeYearQ::usage="chineseLeapSolsticeYearQ[gYear] returns True if the Chinese solstice year (sui) starting in the year before the given Gregorian year has 13 months."; chineseLeapMonth::usage="chineseLeapMonth[gYear] gives the number of the month that is repeated if the Chinese year starting in the given Gregorian year is a Chinese leap year, and returns nothing if the given Gregorian year is not a Chinese leap year."; chineseLeapMonthQ::usage="chineseLeapMonthQ[gYear, n] returns True if the nth month of the Chinese year starting in the given Gregorian year has a leap month."; winterSolstice::usage="winterSolstice[gYear] gives the Gregorian date of the winter solstice of the given Gregorian year."; z12::usage="z12[gYear] gives the Gregorian date of the 12th zhong qi (major solar term) of the given Gregorian year."; liChun::usage="liChun[gYear] gives the Gregorian date of the li chun (first minor solar term) of the given Gregorian year."; z1::usage="z1[gYear] gives the Gregorian date of the 1st zhong qi (major solar term) of the given Gregorian year."; z2::usage="z2[gYear] gives the Gregorian date of the 2nd zhong qi (major solar term) of the given Gregorian year."; chineseNewYearData::usage="chineseNewYearData[gYear] gives the Gregorian date of the astronomical events necessary to determine the Gregorian date of Chinese New Year of the given Gregorian year and any possible leap months for months 11, 12 and 1."; mChineseNewYear::usage="mtChineseNewYear[gYear] gives the moment (fixed day with fractional part indicating time of day) for ChineseNewYear[gYear]."; tChineseNewYear::usage="tChineseNewYear[gYear] gives the Gregorian day and time for ChineseNewYear[gYear]."; mChineseNewMoonOnOrAfter::usage="mChineseNewMoonOnOrAfter[fDate] gives the moment (fixed day with fractional part indicating time of day) for ChineseNewMoonOnOrAfter[fDate]."; tChineseNewMoonOnOrAfter::usage="tChineseNewMoonOnOrAfter[fDate] gives the Gregorian day and time for ChineseNewMoonOnOrAfter[fDate]."; tMajorSolarTermOnOrAfter::usage="tMajorSolarTermOnOrAfter[fDate] gives the Gregorian day and time for MajorSolarTermOnOrAfter[fDate]."; tMinorSolarTermOnOrAfter::usage="tMinorSolarTermOnOrAfter[fDate] gives the Gregorian day and time for MinorSolarTermOnOrAfter[fDate]."; daysToLiChun::usage="daysToLiChun[gYear] gives the number of days between li chun (the first minor solar term) and Chinese New Year of the given Gregorian and the new moons before and after New Year."; timeToLiChun::usage="timeToLiChun[gYear] gives the time between li chun (the first minor solar term) and Chinese New Year of the given Gregorian and the new moons before and after New Year."; liChunErrorBetween::usage="liChunErrorBetween[gYear1, gYear2] lists the years between the two given Gregorian years when Chinese New Year was not the new moon closest to li chun (the first minor solar term)."; lateLiChunBetween::usage="lateLiChunBetween[gYear1, gYear2] lists the years between the two given Gregorian years in which the time between the new moon following Chinese New Year and li chun (the first minor solar term) is less than 16 days."; z12ErrorBetween::usage="z12ErrorBetween[gYear1, gYear2] lists the years between the two given Gregorian years in which the z12 rule fails."; chineseLeapYearsBetween::usage="chineseLeapYearsBetween[gYear1, gYear2] lists all the Gregorian years between the two given Gregorian years that are Chinese leap years."; chineseLeapMonthsBetween::usage="chineseLeapMonthsBetween[gYear1, gYear2] lists the Gregorian year and month number for the months that have a leap month between the two given Gregorian years, and the total number of repeats for each month."; nthChineseLeapMonthsBetween::usage="nthChineseLeapMonthsBetween[gYear1, gYear2, n] counts the number of time the nth month is repeated between the two given Gregorian years."; chineseNewYearsBetween::usage="chineseNewYearsBetween[gYear1, gYear2] displays the Gregorian dates of Chinese New Year between the two given Gregorian years, and gives a list and a table showing the number of times Chinese New Year falls on the days between January 20 and February 21 between the two given Gregorian years."; lengthOfChineseYear::usage="lengthOfChineseYear[gYear] computes the number of days in the Chinese year starting in the given Gregorian year."; lengthOfChineseYearsBetween::usage="lengthOfChineseYearsBetween[gYear1, gYear2] displays the number of days in the Chinese years between the two given Gregorian years and lists how often the different lengths occur."; lengthOfChineseMonthsBetween::usage="lengthOfChineseMonthsBetween[fDate1, fDate2] determines if the months between the two given fixed dates are short or long."; stringsOfChineseMonthsBetween::usage="stringsOfChineseMonthsBetween[fDate1, fDate2] determines if there are strings of 3 short or 4 or 5 long months between the two given fixed dates."; chineseFullMoonAfter::usage="chineseFullMoonAfter[fDate] gives the fixed date for the first Chinese full moon after the given fixed date."; timeOfChineseFullMoonAfter::usage="timeOfChineseFullMoonAfter[fDate] gives the time for the first Chinese full moon after the given fixed date."; dayOfChineseFullMoonBetween::usage="dayOfChineseFullMoonBetween[gYear1, gYear2] gives the day of the full moon in the Chinese months between Chinese New Year of the two given Gregorian years."; solsticeYear::usage="solsticeYear[fDate] gives the Gregorian number of the solstice year containing the given fixed date."; winterSolsticeOnOrBefore::usage="winterSolsticeOnOrBefore[fDate] gives the fixed date of the winter solstice on the day of or before the given fixed date."; fakeLeapMonthsBetween::usage="fakeLeapMonthsBetween[gYear1, gYear2] lists the fake leap months (non-leap months without any zhong qi) between Chinese New Year of the two given Gregorian years."; twoZhongQisBetween::usage="twoZhongQisBetween[gYear1, gYear2] lists the months that contain two zhong qis between Chinese New Year of the two given Gregorian years."; twoJieQisBetween::usage="twoJieQisBetween[gYear1, gYear2] lists the months that contain two jie qis between Chinese New Year of the two given Gregorian years."; (**************** START OF PRIVATE CODE ****************) Begin["`Private`"] nthChineseNewMoonOnOrAfterChineseNewYear[gYear_, n_]:= Fold[ (Calendrica`ChineseNewMoonOnOrAfter[#1+#2])&, Calendrica`ChineseNewYear[gYear], Table[1, {n-1}] ] (* This does not take into account a possible leap month *) nthChineseMonth[gYear_, n_, leap_:0]:= Gregorian[ If[chineseLeapYearQ[gYear], If[leap == 1, nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n + 1], If[Calendrica`PriorLeapMonthQ[ Calendrica`ChineseNewYear[gYear], nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n] ], nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n + 1], nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n] ] ], nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n] ] ] (* This takes into account a possible leap month *) chineseNewMoonsInYear[gYear_]:= Map[Gregorian, FoldList[ (Calendrica`ChineseNewMoonOnOrAfter[#1+#2])&, Calendrica`ChineseNewYear[gYear], Table[1, {If[chineseLeapYearQ[gYear], 12, 11]}] ] ] majorSolarTermsInYear[gYear_] := Map[Gregorian, Map[Floor, FoldList[(Calendrica`MajorSolarTermOnOrAfter[Floor[#1 + #2]]) &, Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, February[], 1]]], Table[1, {11}] ] ] ] chineseLeapYearQ[gYear_]:= Round[ (Calendrica`ChineseNewYear[gYear+1] - Calendrica`ChineseNewYear[gYear] ) / Calendrica`MeanSynodicMonth[] ] == 13 chineseLeapSolsticeYearQ[gYear_] := Round[ (Calendrica`ChineseNewMoonOnOrAfter[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, December[], 15]]] + 1]] - Calendrica`ChineseNewMoonOnOrAfter[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear - 1, December[], 15]]] + 1] ] )/ Calendrica`MeanSynodicMonth[] ] == 13 chineseLeapMonth[gYear_]:= Module[{i}, If[chineseLeapYearQ[gYear], If[chineseLeapSolsticeYearQ[gYear], For[i=2, i<= 11, i++, If[Calendrica`NoMajorSolarTermQ[ nthChineseNewMoonOnOrAfterChineseNewYear[gYear, i]], Return[i-1] ] ], For[i=12, i<= 13, i++, If[Calendrica`NoMajorSolarTermQ[ nthChineseNewMoonOnOrAfterChineseNewYear[gYear, i]], Return[i-1] ] ] ] ] ] chineseLeapMonthQ[gYear_, n_]:= (chineseLeapYearQ[gYear] && If[n < 11, chineseLeapSolsticeYearQ[gYear], chineseLeapSolsticeYearQ[gYear + 1] ] && Calendrica`NoMajorSolarTermQ[ nthChineseNewMoonOnOrAfterChineseNewYear[gYear, n + 1] ] && If[n > 1,!chineseLeapMonthQ[gYear, n - 1],True] ) winterSolstice[gYear_]:= Gregorian[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, December[], 1]] ] ] ] z12[gYear_]:= Gregorian[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, January[], 1]] ] ] ] liChun[gYear_]:= Gregorian[ Floor[ Calendrica`MinorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, February[], 1]] ] ] ] z1[gYear_]:= Gregorian[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, February[], 1]] ] ] ] z2[gYear_]:= Gregorian[ Floor[ Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, March[], 1]] ] ] ] chineseNewYearData[gYear_]:= (Print["Winter solstice: "winterSolstice[gYear-1]]; Print["Month 11+: "Gregorian[nthChineseNewMoonOnOrAfterChineseNewYear[gYear-1,12]]]; Print["zhong qi 12: "z12[gYear-1]]; If[(chineseLeapYearQ[gYear-1] && chineseLeapSolsticeYearQ[gYear]), Print["Month 11++: "Gregorian[nthChineseNewMoonOnOrAfterChineseNewYear[gYear-1,13]]]]; Print["Chinese New Year:"Gregorian[nthChineseNewMoonOnOrAfterChineseNewYear[gYear,1]]]; Print["Li chun: "liChun[gYear]]; Print["zhong qi 1: "z1[gYear]]; Print["Month 1+: "Gregorian[nthChineseNewMoonOnOrAfterChineseNewYear[gYear,2]]]; Print["zhong qi 2: "z2[gYear]]; Print["Month 1++: "Gregorian[nthChineseNewMoonOnOrAfterChineseNewYear[gYear,3]]] ) mChineseNewYear[gYear_]:= Module[{s1, s2, m1, m2, m11}, s1=Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear - 1, December[], 15]]]; s2=Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, December[], 15]]]; m1=Calendrica`ChineseNewMoonOnOrAfter[Floor[s1 + 1]]; m2=Calendrica`ChineseNewMoonOnOrAfter[Floor[m1 + 1]]; m11=Calendrica`ChineseNewMoonBefore[Floor[s2 + 1]]; If[Round[(m11 - m1) / Calendrica`MeanSynodicMonth[]] == 12 && (Calendrica`NoMajorSolarTermQ[Floor[m1]] || Calendrica`NoMajorSolarTermQ[Floor[m2]] ), mChineseNewMoonOnOrAfter[Floor[m2 + 1]], mChineseNewMoonOnOrAfter[Floor[m1 + 1]] ] ] tChineseNewYear[gYear_]:= Print[ Gregorian[Floor[mChineseNewYear[gYear]]], "," TimeOfDay[mChineseNewYear[gYear]] ] mChineseNewMoonOnOrAfter[date_Integer] := Module[{tee}, tee = Calendrica`NewMoonAfter[Calendrica`MidnightInChina[date]]; Calendrica`StandardFromUniversal[ tee,Calendrica`ChineseLocation[tee] ] ] tChineseNewMoonOnOrAfter[fDate_]:= Print[ Gregorian[Floor[mChineseNewMoonOnOrAfter[fDate]]], "," TimeOfDay[mChineseNewMoonOnOrAfter[fDate]] ] tMajorSolarTermOnOrAfter[fDate_]:= Print[ Gregorian[Floor[Calendrica`MajorSolarTermOnOrAfter[fDate]]], "," TimeOfDay[Calendrica`MajorSolarTermOnOrAfter[fDate]] ] tMinorSolarTermOnOrAfter[fDate_]:= Print[ Gregorian[Floor[Calendrica`MinorSolarTermOnOrAfter[fDate]]], "," TimeOfDay[Calendrica`MinorSolarTermOnOrAfter[fDate]] ] daysToLiChun[gYear_]:= Module[{C,L,next,last}, C=Calendrica`ChineseNewYear[gYear]; L=Floor[Calendrica`MinorSolarTermOnOrAfter[ ToFixed[Gregorian[gYear, February[], 2]]]]; next=Calendrica`ChineseNewMoonOnOrAfter[Floor[C+1]]; last=Calendrica`ChineseNewMoonOnOrAfter[Floor[C-35]]; Print[gYear,", CNY-1 to LC: ",L-last,", CNY to LC: ",Abs[L-C],", CNY+1 to LC: ",next-L] ] timeToLiChun[gYear_]:= Module[{C,L,next,last}, C=mChineseNewYear[gYear]; L=Calendrica`MinorSolarTermOnOrAfter[ToFixed[Gregorian[gYear, February[], 2]]]; next=mChineseNewMoonOnOrAfter[Floor[C+1]]; last=mChineseNewMoonOnOrAfter[Floor[C-35]]; Print[gYear,", CNY-1 to LC: ",L-last,", CNY to LC: ",Abs[L-C],", CNY+1 to LC: ",next-L] ] liChunErrorBetween[gYear1_,gYear2_]:= Module[{C,L,next,last}, For[i=gYear1, i<=gYear2, i++, C=mChineseNewYear[i]; L=Calendrica`MinorSolarTermOnOrAfter[ToFixed[Gregorian[i, February[], 1]]]; next=mChineseNewMoonOnOrAfter[Floor[C+1]]; last=mChineseNewMoonOnOrAfter[Floor[C-35]]; If[Abs[L-C]> L-last || Abs[L-C]> next-L , Print[i,", CNY-1 to LC: ",L-last,", CNY to LC: ",Abs[L-C],", CNY+1 to LC: ",next-L] ] ] ] lateLiChunBetween[gYear1_,gYear2_]:= Module[{C,L,next,last}, For[i=gYear1, i<=gYear2, i++, C=mChineseNewYear[i]; L=Calendrica`MinorSolarTermOnOrAfter[ToFixed[Gregorian[i, February[], 1]]]; next=mChineseNewMoonOnOrAfter[Floor[C+1]]; last=mChineseNewMoonOnOrAfter[Floor[C-35]]; If[16> next-L , Print[i,", CNY-1 to LC: ",L-last,", CNY to LC: ",Abs[L-C],", CNY+1 to LC: ",next-L] ] ] ] z12ErrorBetween[gYear1_, gYear2_]:= Module[{z12,m12}, For[i=gYear1, i<=gYear2, i++, z12=MajorSolarTermOnOrAfter[ToFixed[Gregorian[i,1,1]]]; m12=mChineseNewMoonOnOrAfter[ Floor[MajorSolarTermOnOrAfter[ToFixed[Gregorian[i-1,12,1]]]+1]]; If[Ceiling[z12] Left, ChartLabels -> M] ] nthChineseLeapMonthsBetween[gYear1_, gYear2_, n_]:= Module[{c=0}, For[i=gYear1, i<=gYear2, i++, If[chineseLeapMonthQ[i, n], Print[i]; c++; ] ]; Print[c] ] chineseNewYearsBetween[gYear1_, gYear2_]:= Module[{L=Table[0, {33}], M=Table[0, {33}], N=Table[0, {33}]}, For[i=gYear1, i<= gYear2, i++, (If[CMonth[Gregorian[Calendrica`ChineseNewYear[i]]]==1, L[[CDay[Gregorian[Calendrica`ChineseNewYear[i]]]-19]] ++, L[[CDay[Gregorian[Calendrica`ChineseNewYear[i]]]+12]] ++ ]; j=Gregorian[Calendrica`ChineseNewYear[i]]; Print[i,": ",j] ) ]; For[k=1,k<=12,k++, M[[k]]=ToString[k+19]<>"/1:"<>ToString[L[[k]]] ]; For[k=13,k<=33,k++, M[[k]]=ToString[k-12]<>"/2:"<>ToString[L[[k]]] ]; For[k=1,k<=12,k++, N[[k]]=ToString[k+19]<>"/1" ]; For[k=13,k<=33,k++, N[[k]]=ToString[k-12]<>"/2" ]; Print[M]; BarChart[L, BarOrigin -> Left, ChartLabels -> N] ] lengthOfChineseYear[gYear_]:= Calendrica`ChineseNewYear[gYear+1]-Calendrica`ChineseNewYear[gYear] lengthOfChineseYearsBetween[gYear1_, gYear2_]:= Module[{L=Table[0, {7}], M=Table[0, {7}]}, For[i=gYear1, i<= gYear2, i++, (Which[ lengthOfChineseYear[i]==353,L[[1]]++, lengthOfChineseYear[i]==354,L[[2]]++, lengthOfChineseYear[i]==355,L[[3]]++, lengthOfChineseYear[i]==383,L[[4]]++, lengthOfChineseYear[i]==384,L[[5]]++, lengthOfChineseYear[i]==385,L[[6]]++, True,L[[7]]++ ]; j=lengthOfChineseYear[i]; Print[i,": ",j] ) ]; For[k=1,k<=3,k++, M[[k]]=ToString[352+k]<>":"<>ToString[L[[k]]] ]; For[k=4,k<=6,k++, M[[k]]=ToString[379+k]<>":"<>ToString[L[[k]]] ]; M[[7]]="Exceptions:"<>ToString[L[[7]]]; M ] lengthOfChineseMonthsBetween[fDate1_, fDate2_]:= Module[{t=fDate1}, While[(t=Calendrica`ChineseNewMoonOnOrAfter[t+1])":"<>ToString[L[[k]]] ]; Print[M]; N[Sum[L[[i]] (i+13),{i,1,4}]/Sum[L[[i]] ,{i,1,4}]] ] solsticeYear[fDate_]:= Module[ { c=CYear[Gregorian[fDate]], s=Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[CYear[Gregorian[fDate]], December[], 1]] ] }, If[fDate< Floor[s], c, c+1] ] winterSolsticeOnOrBefore[fDate_]:= Module[ {s0=Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[CYear[Gregorian[fDate]]-1, December[], 1]] ], s1=Calendrica`MajorSolarTermOnOrAfter[ ToFixed[Gregorian[CYear[Gregorian[fDate]], December[], 1]] ] }, If[fDate< Floor[s1], Floor[s0], Floor[s1]] ] fakeLeapMonthsBetween[gYear1_, gYear2_]:= Module[ {c, t=Calendrica`ChineseNewYear[gYear1], t1=Calendrica`ChineseNewYear[gYear2] }, While[t