`
JAVA海洋
  • 浏览: 618197 次
  • 性别: Icon_minigender_1
  • 来自: 太原
社区版块
存档分类
最新评论

中国年历算法和程式

阅读更多

中国年历算法和程式

本文摘自“和荣笔记-中国农历二百年算法及年历”

中国公历算法

中国公历算法不是太难,关键是星期值的确定。这里给出了简单算法:

   public static int dayOfWeek(int y, int m, int d) {
      int w = 1; // 公历一年一月一日是星期一,所以起始值为星期日
      y = (y-1)%400 + 1; // 公历星期值分部 400 年循环一次
      int ly = (y-1)/4; // 闰年次数
      ly = ly - (y-1)/100;
      ly = ly + (y-1)/400;
      int ry = y - 1 - ly; // 常年次数
      w = w + ry; // 常年星期值增一
      w = w + 2*ly; // 闰年星期值增二
      w = w + dayOfYear(y,m,d); 
      w = (w-1)%7 + 1;
      return w;
   }


中国农历算法

根公历相比,中国农历的算法相当复杂。我在网上找的算法之中,eleworld.com的算法是最好的一个。这个算法使用了大量的数据来确定农历月份和节气的分部,它仅实用于公历1901年到2100年之间的200年。

中国农历计算程式

跟据eleworld.com提供的算法,我写了下面这个程式:
[HTML]<pre>
/**
*ChineseCalendarGB.java
*Copyright(c)1997-2002byDr.HerongYang.http://www.herongyang.com/
*中国农历算法-实用于公历1901年至2100年之间的200年
*/
importjava.text.*;
importjava.util.*;
classChineseCalendarGB{
privateintgregorianYear;
privateintgregorianMonth;
privateintgregorianDate;
privatebooleanisGregorianLeap;
privateintdayOfYear;
privateintdayOfWeek;//周日一星期的第一天
privateintchineseYear;
privateintchineseMonth;//负数表示闰月
privateintchineseDate;
privateintsectionalTerm;
privateintprincipleTerm;
privatestaticchar[]daysInGregorianMonth=
{31,28,31,30,31,30,31,31,30,31,30,31};
privatestaticString[]stemNames=
{"甲","乙","丙","丁","戊","己","庚","辛","壬","癸"};
privatestaticString[]branchNames=
{"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"};
privatestaticString[]animalNames=
{"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"};
publicstaticvoidmain(String[]arg){
ChineseCalendarGBc=newChineseCalendarGB();
Stringcmd="day";
inty=1901;
intm=1;
intd=1;
if(arg.length>0)cmd=arg[0];
if(arg.length>1)y=Integer.parseInt(arg[1]);
if(arg.length>2)m=Integer.parseInt(arg[2]);
if(arg.length>3)d=Integer.parseInt(arg[3]);
c.setGregorian(y,m,d);
c.computeChineseFields();
c.computeSolarTerms();
if(cmd.equalsIgnoreCase("year")){
String[]t=c.getYearTable();
for(inti=0;i<t.length;i++)System.out.println(t[i]);
}elseif(cmd.equalsIgnoreCase("month")){
String[]t=c.getMonthTable();
for(inti=0;i<t.length;i++)System.out.println(t[i]);
}else{
System.out.println(c.toString());
}
}
publicChineseCalendarGB(){
setGregorian(1901,1,1);
}
publicvoidsetGregorian(inty,intm,intd){
gregorianYear=y;
gregorianMonth=m;
gregorianDate=d;
isGregorianLeap=isGregorianLeapYear(y);
dayOfYear=dayOfYear(y,m,d);
dayOfWeek=dayOfWeek(y,m,d);
chineseYear=0;
chineseMonth=0;
chineseDate=0;
sectionalTerm=0;
principleTerm=0;
}
publicstaticbooleanisGregorianLeapYear(intyear){
booleanisLeap=false;
if(year%4==0)isLeap=true;
if(year%100==0)isLeap=false;
if(year%400==0)isLeap=true;
returnisLeap;
}
publicstaticintdaysInGregorianMonth(inty,intm){
intd=daysInGregorianMonth[m-1];
if(m==2&&isGregorianLeapYear(y))d++;//公历闰年二月多一天
returnd;
}
publicstaticintdayOfYear(inty,intm,intd){
intc=0;
for(inti=1;i<m;i++){
c=c+daysInGregorianMonth(y,i);
}
c=c+d;
returnc;
}
publicstaticintdayOfWeek(inty,intm,intd){
intw=1;//公历一年一月一日是星期一,所以起始值为星期日
y=(y-1)%400+1;//公历星期值分部400年循环一次
intly=(y-1)/4;//闰年次数
ly=ly-(y-1)/100;
ly=ly+(y-1)/400;
intry=y-1-ly;//常年次数
w=w+ry;//常年星期值增一
w=w+2*ly;//闰年星期值增二
w=w+dayOfYear(y,m,d);
w=(w-1)%7+1;
returnw;
}
privatestaticchar[]chineseMonths={
//农历月份大小压缩表,两个字节表示一年。两个字节共十六个二进制位数,
//前四个位数表示闰月月份,后十二个位数表示十二个农历月份的大小。
0x00,0x04,0xad,0x08,0x5a,0x01,0xd5,0x54,0xb4,0x09,0x64,0x05,0x59,0x45,
0x95,0x0a,0xa6,0x04,0x55,0x24,0xad,0x08,0x5a,0x62,0xda,0x04,0xb4,0x05,
0xb4,0x55,0x52,0x0d,0x94,0x0a,0x4a,0x2a,0x56,0x02,0x6d,0x71,0x6d,0x01,
0xda,0x02,0xd2,0x52,0xa9,0x05,0x49,0x0d,0x2a,0x45,0x2b,0x09,0x56,0x01,
0xb5,0x20,0x6d,0x01,0x59,0x69,0xd4,0x0a,0xa8,0x05,0xa9,0x56,0xa5,0x04,
0x2b,0x09,0x9e,0x38,0xb6,0x08,0xec,0x74,0x6c,0x05,0xd4,0x0a,0xe4,0x6a,
0x52,0x05,0x95,0x0a,0x5a,0x42,0x5b,0x04,0xb6,0x04,0xb4,0x22,0x6a,0x05,
0x52,0x75,0xc9,0x0a,0x52,0x05,0x35,0x55,0x4d,0x0a,0x5a,0x02,0x5d,0x31,
0xb5,0x02,0x6a,0x8a,0x68,0x05,0xa9,0x0a,0x8a,0x6a,0x2a,0x05,0x2d,0x09,
0xaa,0x48,0x5a,0x01,0xb5,0x09,0xb0,0x39,0x64,0x05,0x25,0x75,0x95,0x0a,
0x96,0x04,0x4d,0x54,0xad,0x04,0xda,0x04,0xd4,0x44,0xb4,0x05,0x54,0x85,
0x52,0x0d,0x92,0x0a,0x56,0x6a,0x56,0x02,0x6d,0x02,0x6a,0x41,0xda,0x02,
0xb2,0xa1,0xa9,0x05,0x49,0x0d,0x0a,0x6d,0x2a,0x09,0x56,0x01,0xad,0x50,
0x6d,0x01,0xd9,0x02,0xd1,0x3a,0xa8,0x05,0x29,0x85,0xa5,0x0c,0x2a,0x09,
0x96,0x54,0xb6,0x08,0x6c,0x09,0x64,0x45,0xd4,0x0a,0xa4,0x05,0x51,0x25,
0x95,0x0a,0x2a,0x72,0x5b,0x04,0xb6,0x04,0xac,0x52,0x6a,0x05,0xd2,0x0a,
0xa2,0x4a,0x4a,0x05,0x55,0x94,0x2d,0x0a,0x5a,0x02,0x75,0x61,0xb5,0x02,
0x6a,0x03,0x61,0x45,0xa9,0x0a,0x4a,0x05,0x25,0x25,0x2d,0x09,0x9a,0x68,
0xda,0x08,0xb4,0x09,0xa8,0x59,0x54,0x03,0xa5,0x0a,0x91,0x3a,0x96,0x04,
0xad,0xb0,0xad,0x04,0xda,0x04,0xf4,0x62,0xb4,0x05,0x54,0x0b,0x44,0x5d,
0x52,0x0a,0x95,0x04,0x55,0x22,0x6d,0x02,0x5a,0x71,0xda,0x02,0xaa,0x05,
0xb2,0x55,0x49,0x0b,0x4a,0x0a,0x2d,0x39,0x36,0x01,0x6d,0x80,0x6d,0x01,
0xd9,0x02,0xe9,0x6a,0xa8,0x05,0x29,0x0b,0x9a,0x4c,0xaa,0x08,0xb6,0x08,
0xb4,0x38,0x6c,0x09,0x54,0x75,0xd4,0x0a,0xa4,0x05,0x45,0x55,0x95,0x0a,
0x9a,0x04,0x55,0x44,0xb5,0x04,0x6a,0x82,0x6a,0x05,0xd2,0x0a,0x92,0x6a,
0x4a,0x05,0x55,0x0a,0x2a,0x4a,0x5a,0x02,0xb5,0x02,0xb2,0x31,0x69,0x03,
0x31,0x73,0xa9,0x0a,0x4a,0x05,0x2d,0x55,0x2d,0x09,0x5a,0x01,0xd5,0x48,
0xb4,0x09,0x68,0x89,0x54,0x0b,0xa4,0x0a,0xa5,0x6a,0x95,0x04,0xad,0x08,
0x6a,0x44,0xda,0x04,0x74,0x05,0xb0,0x25,0x54,0x03
};
//初始日,公历农历对应日期:
//公历1901年1月1日,对应农历4598年11月11日
privatestaticintbaseYear=1901;
privatestaticintbaseMonth=1;
privatestaticintbaseDate=1;
privatestaticintbaseIndex=0;
privatestaticintbaseChineseYear=4598-1;
privatestaticintbaseChineseMonth=11;
privatestaticintbaseChineseDate=11;
publicintcomputeChineseFields(){
if(gregorianYear<1901||gregorianYear>2100)return1;
intstartYear=baseYear;
intstartMonth=baseMonth;
intstartDate=baseDate;
chineseYear=baseChineseYear;
chineseMonth=baseChineseMonth;
chineseDate=baseChineseDate;
//第二个对应日,用以提高计算效率
//公历2000年1月1日,对应农历4697年11月25日
if(gregorianYear>=2000){
startYear=baseYear+99;
startMonth=1;
startDate=1;
chineseYear=baseChineseYear+99;
chineseMonth=11;
chineseDate=25;
}
intdaysDiff=0;
for(inti=startYear;i<gregorianYear;i++){
daysDiff+=365;
if(isGregorianLeapYear(i))daysDiff+=1;//leapyear
}
for(inti=startMonth;i<gregorianMonth;i++){
daysDiff+=daysInGregorianMonth(gregorianYear,i);
}
daysDiff+=gregorianDate-startDate;

chineseDate+=daysDiff;
intlastDate=daysInChineseMonth(chineseYear,chineseMonth);
intnextMonth=nextChineseMonth(chineseYear,chineseMonth);
while(chineseDate>lastDate){
if(Math.abs(nextMonth)<Math.abs(chineseMonth))chineseYear++;
chineseMonth=nextMonth;
chineseDate-=lastDate;
lastDate=daysInChineseMonth(chineseYear,chineseMonth);
nextMonth=nextChineseMonth(chineseYear,chineseMonth);
}
return0;
}
privatestaticint[]bigLeapMonthYears={
//大闰月的闰年年份
6,14,19,25,33,36,38,41,44,52,
55,79,117,136,147,150,155,158,185,193
};
publicstaticintdaysInChineseMonth(inty,intm){
//注意:闰月m<0
intindex=y-baseChineseYear+baseIndex;
intv=0;
intl=0;
intd=30;
if(1<=m&&m<=8){
v=chineseMonths[2*index];
l=m-1;
if(((v>>l)&0x01)==1)d=29;
}elseif(9<=m&&m<=12){
v=chineseMonths[2*index+1];
l=m-9;
if(((v>>l)&0x01)==1)d=29;
}else{
v=chineseMonths[2*index+1];
v=(v>>4)&0x0F;
if(v!=Math.abs(m)){
d=0;
}else{
d=29;
for(inti=0;i<bigLeapMonthYears.length;i++){
if(bigLeapMonthYears[i]==index){
d=30;
break;
}
}
}
}
returnd;
}
publicstaticintnextChineseMonth(inty,intm){
intn=Math.abs(m)+1;
if(m>0){
intindex=y-baseChineseYear+baseIndex;
intv=chineseMonths[2*index+1];
v=(v>>4)&0x0F;
if(v==m)n=-m;
}
if(n==13)n=1;
returnn;
}
privatestaticchar[][]sectionalTermMap={
{7,6,6,6,6,6,6,6,6,5,6,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,5,5},
{5,4,5,5,5,4,4,5,5,4,4,4,4,4,4,4,4,3,4,4,4,3,3,4,4,3,3,3},
{6,6,6,7,6,6,6,6,5,6,6,6,5,5,6,6,5,5,5,6,5,5,5,5,4,5,5,5,5},
{5,5,6,6,5,5,5,6,5,5,5,5,4,5,5,5,4,4,5,5,4,4,4,5,4,4,4,4,5},
{6,6,6,7,6,6,6,6,5,6,6,6,5,5,6,6,5,5,5,6,5,5,5,5,4,5,5,5,5},
{6,6,7,7,6,6,6,7,6,6,6,6,5,6,6,6,5,5,6,6,5,5,5,6,5,5,5,5,4,5,5,5,5},
{7,8,8,8,7,7,8,8,7,7,7,8,7,7,7,7,6,7,7,7,6,6,7,7,6,6,6,7,7},
{8,8,8,9,8,8,8,8,7,8,8,8,7,7,8,8,7,7,7,8,7,7,7,7,6,7,7,7,6,6,7,7,7},
{8,8,8,9,8,8,8,8,7,8,8,8,7,7,8,8,7,7,7,8,7,7,7,7,6,7,7,7,7},
{9,9,9,9,8,9,9,9,8,8,9,9,8,8,8,9,8,8,8,8,7,8,8,8,7,7,8,8,8},
{8,8,8,8,7,8,8,8,7,7,8,8,7,7,7,8,7,7,7,7,6,7,7,7,6,6,7,7,7},
{7,8,8,8,7,7,8,8,7,7,7,8,7,7,7,7,6,7,7,7,6,6,7,7,6,6,6,7,7}
};
privatestaticchar[][]sectionalTermYear={
{13,49,85,117,149,185,201,250,250},
{13,45,81,117,149,185,201,250,250},
{13,48,84,112,148,184,200,201,250},
{13,45,76,108,140,172,200,201,250},
{13,44,72,104,132,168,200,201,250},
{5,33,68,96,124,152,188,200,201},
{29,57,85,120,148,176,200,201,250},
{13,48,76,104,132,168,196,200,201},
{25,60,88,120,148,184,200,201,250},
{16,44,76,108,144,172,200,201,250},
{28,60,92,124,160,192,200,201,250},
{17,53,85,124,156,188,200,201,250}
};
privatestaticchar[][]principleTermMap={
{21,21,21,21,21,20,21,21,21,20,20,21,21,20,20,20,20,20,20,20,20,19,
20,20,20,19,19,20},
{20,19,19,20,20,19,19,19,19,19,19,19,19,18,19,19,19,18,18,19,19,18,
18,18,18,18,18,18},
{21,21,21,22,21,21,21,21,20,21,21,21,20,20,21,21,20,20,20,21,20,20,
20,20,19,20,20,20,20},
{20,21,21,21,20,20,21,21,20,20,20,21,20,20,20,20,19,20,20,20,19,19,
20,20,19,19,19,20,20},
{21,22,22,22,21,21,22,22,21,21,21,22,21,21,21,21,20,21,21,21,20,20,
21,21,20,20,20,21,21},
{22,22,22,22,21,22,22,22,21,21,22,22,21,21,21,22,21,21,21,21,20,21,
21,21,20,20,21,21,21},
{23,23,24,24,23,23,23,24,23,23,23,23,22,23,23,23,22,22,23,23,22,22,
22,23,22,22,22,22,23},
{23,24,24,24,23,23,24,24,23,23,23,24,23,23,23,23,22,23,23,23,22,22,
23,23,22,22,22,23,23},
{23,24,24,24,23,23,24,24,23,23,23,24,23,23,23,23,22,23,23,23,22,22,
23,23,22,22,22,23,23},
{24,24,24,24,23,24,24,24,23,23,24,24,23,23,23,24,23,23,23,23,22,23,
23,23,22,22,23,23,23},
{23,23,23,23,22,23,23,23,22,22,23,23,22,22,22,23,22,22,22,22,21,22,
22,22,21,21,22,22,22},
{22,22,23,23,22,22,22,23,22,22,22,22,21,22,22,22,21,21,22,22,21,21,
21,22,21,21,21,21,22}
};
privatestaticchar[][]principleTermYear={
{13,45,81,113,149,185,201},
{21,57,93,125,161,193,201},
{21,56,88,120,152,188,200,201},
{21,49,81,116,144,176,200,201},
{17,49,77,112,140,168,200,201},
{28,60,88,116,148,180,200,201},
{25,53,84,112,144,172,200,201},
{29,57,89,120,148,180,200,201},
{17,45,73,108,140,168,200,201},
{28,60,92,124,160,192,200,201},
{16,44,80,112,148,180,200,201},
{17,53,88,120,156,188,200,201}
};
publicintcomputeSolarTerms(){
if(gregorianYear<1901||gregorianYear>2100)return1;
sectionalTerm=sectionalTerm(gregorianYear,gregorianMonth);
principleTerm=principleTerm(gregorianYear,gregorianMonth);
return0;
}
publicstaticintsectionalTerm(inty,intm){
if(y<1901||y>2100)return0;
intindex=0;
intry=y-baseYear+1;
while(ry>=sectionalTermYear[m-1][index])index++;
intterm=sectionalTermMap[m-1][4*index+ry%4];
if((ry==121)&&(m==4))term=5;
if((ry==132)&&(m==4))term=5;
if((ry==194)&&(m==6))term=6;
returnterm;
}
publicstaticintprincipleTerm(inty,intm){
if(y<1901||y>2100)return0;
intindex=0;
intry=y-baseYear+1;
while(ry>=principleTermYear[m-1][index])index++;
intterm=principleTermMap[m-1][4*index+ry%4];
if((ry==171)&&(m==3))term=21;
if((ry==181)&&(m==5))term=21;
returnterm;
}
publicStringtoString(){
StringBufferbuf=newStringBuffer();
buf.append("GregorianYear:"+gregorianYear+"\n");
buf.append("GregorianMonth:"+gregorianMonth+"\n");
buf.append("GregorianDate:"+gregorianDate+"\n");
buf.append("IsLeapYear:"+isGregorianLeap+"\n");
buf.append("DayofYear:"+dayOfYear+"\n");
buf.append("DayofWeek:"+dayOfWeek+"\n");
buf.append("ChineseYear:"+chineseYear+"\n");
buf.append("HeavenlyStem:"+((chineseYear-1)%10)+"\n");
buf.append("EarthlyBranch:"+((chineseYear-1)%12)+"\n");
buf.append("ChineseMonth:"+chineseMonth+"\n");
buf.append("ChineseDate:"+chineseDate+"\n");
buf.append("SectionalTerm:"+sectionalTerm+"\n");
buf.append("PrincipleTerm:"+principleTerm+"\n");
returnbuf.toString();
}
publicString[]getYearTable(){
setGregorian(gregorianYear,1,1);
computeChineseFields();
computeSolarTerms();
String[]table=newString[58];//6*9+4
table[0]=getTextLine(27,"公历年历:"+gregorianYear);
table[1]=getTextLine(27,"农历年历:"+(chineseYear+1)
+"("+stemNames[(chineseYear+1-1)%10]
+branchNames[(chineseYear+1-1)%12]
+"-"+animalNames[(chineseYear+1-1)%12]+"年)");
intln=2;
Stringblank=""
+""+"";
String[]mLeft=null;
String[]mRight=null;
for(inti=1;i<=6;i++){
table[ln]=blank;
ln++;
mLeft=getMonthTable();
mRight=getMonthTable();
for(intj=0;j<mLeft.length;j++){
Stringline=mLeft[j]+""+mRight[j];
table[ln]=line;
ln++;
}
}
table[ln]=blank;
ln++;
table[ln]=getTextLine(0,
"##/##-公历日期/农历日期,(*)#月-(闰)农历月第一天");
ln++;
returntable;
}
publicstaticStringgetTextLine(ints,Stringt){
Stringstr=""
+""+"";
if(t!=null&&s<str.length()&&s+t.length()<str.length())
str=str.substring(0,s)+t+str.substring(s+t.length());
returnstr;
}
privatestaticString[]monthNames=
{"一","二","三","四","五","六","七","八","九","十","十一","十二"};
publicString[]getMonthTable(){
setGregorian(gregorianYear,gregorianMonth,1);
computeChineseFields();
computeSolarTerms();
String[]table=newString[8];
Stringtitle=null;
if(gregorianMonth<11)title="";
elsetitle="";
title=title+monthNames[gregorianMonth-1]+"月"
+"";
Stringheader="日一二三四五六";
Stringblank="";
table[0]=title;
table[1]=header;
intwk=2;
Stringline="";
for(inti=1;i<dayOfWeek;i++){
line+=""+'';
}
intdays=daysInGregorianMonth(gregorianYear,gregorianMonth);
for(inti=gregorianDate;i<=days;i++){
line+=getDateString()+'';
rollUpOneDay();
if(dayOfWeek==1){
table[wk]=line;
line="";
wk++;
}
}
for(inti=dayOfWeek;i<=7;i++){
line+=""+'';
}
table[wk]=line;
for(inti=wk+1;i<table.length;i++){
table[i]=blank;
}
for(inti=0;i<table.length;i++){
table[i]=table[i].substring(0,table[i].length()-1);
}

returntable;
}
privatestaticString[]chineseMonthNames=
{"正","二","三","四","五","六","七","八","九","十","冬","腊"};
privatestaticString[]principleTermNames=
{"雨水","春分","谷雨","夏满","夏至","大暑","处暑","秋分","霜降",
"小雪","冬至","大寒"};
privatestaticString[]sectionalTermNames=
{"立春","惊蛰","清明","立夏","芒种","小暑","立秋","白露","寒露",
"立冬","大雪","小寒"};
publicStringgetDateString(){
Stringstr="*/";
Stringgm=String.valueOf(gregorianMonth);
if(gm.length()==1)gm=''+gm;
Stringcm=String.valueOf(Math.abs(chineseMonth));
if(cm.length()==1)cm=''+cm;
Stringgd=String.valueOf(gregorianDate);
if(gd.length()==1)gd=''+gd;
Stringcd=String.valueOf(chineseDate);
if(cd.length()==1)cd=''+cd;
if(gregorianDate==sectionalTerm){
str=""+sectionalTermNames[gregorianMonth-1];
}elseif(gregorianDate==principleTerm){
str=""+principleTermNames[gregorianMonth-1];
}elseif(chineseDate==1&&chineseMonth>0){
str=""+chineseMonthNames[chineseMonth-1]+"月";
}elseif(chineseDate==1&&chineseMonth<0){
str="*"+chineseMonthNames[-chineseMonth-1]+"月";
}else{
str=gd+'/'+cd;
}
returnstr;
}
publicintrollUpOneDay(){
dayOfWeek=dayOfWeek%7+1;
dayOfYear++;
gregorianDate++;
intdays=daysInGregorianMonth(gregorianYear,gregorianMonth);
if(gregorianDate>days){
gregorianDate=1;
gregorianMonth++;
if(gregorianMonth>12){
gregorianMonth=1;
gregorianYear++;
dayOfYear=1;
isGregorianLeap=isGregorianLeapYear(gregorianYear);
}
sectionalTerm=sectionalTerm(gregorianYear,gregorianMonth);
principleTerm=principleTerm(gregorianYear,gregorianMonth);
}
chineseDate++;
days=daysInChineseMonth(chineseYear,chineseMonth);
if(chineseDate>days){
chineseDate=1;
chineseMonth=nextChineseMonth(chineseYear,chineseMonth);
if(chineseMonth==1)chineseYear++;
}
return0;
}
}
</pre>[/HTML]

中国二百年年历1901年至2100年

我用上面这个程式制作了二百年年历,1901年至2100年,全部收录在这本书中。

年历格式说明:

农历日期列在公历日期后面。
节气用节气名称标明。
农历每月第一天用月份名称标明。
例如,2000年一月的表达格式如下:
[HTML]<pre>
一月
日一二三四五六
1/25
2/263/274/285/29立春腊月8/2
9/310/411/512/613/714/815/9
16/1017/1118/1219/1320/14雨水22/16
23/1724/1825/1926/2027/2128/2229/23
30/2431/25
</pre>[/HTML]

其中:

"1/25"-表示公历1号和农历25号。
"立春"-表示节气。
"腊月"-表示农历12月第一天。

------
有关中国年历算法和程式的详细注解和二百年年历,请参考
“和荣笔记-中国农历二百年算法及年历”
-http://www.herongyang.com/year_gb/
分享到:
评论

相关推荐

    易语言天文算法万年历源码

    易语言是一种基于中文编程的计算机程序设计语言,其目标是使普通用户也能轻松进行软件开发。在本案例中,我们关注的是一个特定的项目——"易语言天文算法万年历源码"。这个项目提供了实现天文算法的源代码,用于生成...

    万年历星期的算法(C语言).rar

    万年历星期的算法是计算机科学中一个经典的问题,它涉及到日期计算和模运算等基础知识。在C语言中实现这样的算法,需要理解日期与星期之间的转换规则,以及如何利用编程技巧来高效地处理这些计算。 首先,我们需要...

    日梭万年历(高精度的万年历)V5.0绿色免费版

    日梭万年历是第一款采用现代高精度天文历算算法生成的公历、农历、伊斯兰历(回历)三历对照、信息丰富、年代特长的多功能万年历。时间跨度长达4000年(起自格里历开始实行年之后的1583年,即明朝万历11年,止于公元...

    易语言源代码_万年历.zip

    万年历程序是一个常见的计算机应用,它能够显示公历日期、农历日期、节气、节假日等信息,通常用于查询和计划日程。在易语言中开发这样的程序,我们需要掌握以下几个核心知识点: 1. **易语言基础语法**:易语言的...

    单片机万年历制作全部资料

    单片机万年历制作是一项综合性的工程,它涉及到硬件设计、软件编程、时钟算法等多个方面的知识。在这个项目中,我们将深入探讨如何...这个项目不仅可以提升你的动手能力,还能加深对单片机系统和时间管理算法的理解。

    单片机万年历课程设计

    为了实现万年历功能,还需要编写算法来处理闰年和月份天数的变化。 自动闹钟功能则需要设置一个定时器,用户可以通过按键设定特定的闹钟时间。当达到设定时间时,单片机会触发闹铃提醒。这涉及到中断系统,单片机在...

    C语言课程设计万年历范例.rar

    【标签】"书籍教程-程序语言"表明这个压缩包包含的资料可能是一份教学材料,可能是书籍的一部分或独立的教程文档,专注于C语言的学习。C语言作为一门基础且强大的编程语言,广泛应用于操作系统开发、嵌入式系统、...

    基于JavaScript的万年历设计开题报告.docx

    参考文献涵盖了一系列JavaScript教程和编程实践书籍,以及关于农历转换算法和时间计算方法的专业资料,这些都将为万年历的设计和实现提供理论基础和技术支持。 综上所述,基于JavaScript的万年历设计是一个结合了...

    Proteus 仿真万年历

    - `源代码文件`:.C或.asm文件,实现了万年历的算法和LCD驱动。 - `LCD驱动库`:可能包含针对特定LCD的驱动函数库。 - `说明文档`:可能有项目介绍、使用指南或代码注释。 通过学习和实践这个项目,你可以深入理解...

    wahaha.rar_LCD显示_万年历

    在本项目中,“wahaha.rar_LCD显示_万年历”是一个关于使用C51单片机和LCD显示器来实现万年历功能的实践教程。这个压缩包可能包含了相关的代码示例和参考资料,如“wahaha.txt”和“www.pudn.com.txt”。以下是基于...

    c语言编写的万年历程序(经典)

    如果你在阅读过程中遇到困难,可以参考C语言相关的教程和文档,如K&R(《C程序设计语言》)或在线资源,如C语言中文网。 总的来说,C语言实现的万年历程序是一个综合性的实践项目,涵盖了日期处理、算法设计等多个...

    单片机万年历程序.pdf

    这篇文档是关于如何在ATmega8单片机上编写一个万年历程序的教程,主要涉及C语言编程和单片机RTC(实时时钟)的使用。ATmega8是一款广泛应用的AVR微控制器,它内置了RTC功能,可以用于保持精确的时间。 1. **RTC功能...

    基于51平台的最强万年历的制作

    这篇教程将深入探讨如何使用C语言在51单片机上开发一个强大的万年历程序。 首先,我们来看C语言开发的重要性。C语言是嵌入式系统开发的主流语言,它具有高效、灵活和可移植性强的特点,适合于对硬件资源有限的51...

    c语言万年历源码.zip

    这个项目可能是为了教学或实践目的而创建的,允许开发者研究和理解如何在C语言中实现复杂的日历算法。源代码是程序员可以直接阅读和修改的文本文件,它是软件开发的核心部分,通过阅读和分析源码,我们可以了解到...

    电子万年历设计与制作资料 (2).zip

    本资料包“电子万年历设计与制作资料 (2).zip”包含了一个关于电子万年历的设计与制作的完整教程,旨在帮助你深入理解和实践电子万年历的开发过程。下面我们将详细探讨其中涉及的关键知识点。 首先,电子万年历的...

    自制万年历加备忘录(c++builder)

    源代码是学习和理解软件设计思路、算法运用以及C++Builder特性的宝贵资源。"直接可用"则表明这个程序可以直接编译运行,无需额外的配置或者依赖,对于初学者来说,这降低了尝试和学习的门槛。 标签“自制万年历”...

    日历 万年历 (c语言编写)

    本项目"日历 万年历 (c语言编写)"就是一个很好的实例,它展示了如何利用C语言来创建一个能够显示任意年份和月份的日历程序。下面将详细阐述这个项目的实现原理、涉及的关键知识点以及可能的优化方法。 1. **基本...

    STC89C51RC.rar_stc89c51rc_万年历

    4. **万年历算法**:为了实现万年历功能,程序需要处理闰年规则,比如普通年份能被4整除但不能被100整除的是闰年,或者世纪年份能被400整除的也是闰年。此外,还要考虑到月份的天数,比如2月在闰年和平年中的天数...

    【设计资料】单片机万年历1602显示.zip

    "参考资料"则可能包含了一些教程、手册、API文档或已有的类似项目,为学习和设计提供了额外的支持。 总的来说,这个压缩包中的资源提供了一个完整的单片机万年历项目实例,涵盖了从硬件选择、软件编程到系统集成和...

Global site tag (gtag.js) - Google Analytics