




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
万年历算法 一、 阳历算法具体算法见函数Void get_solar_day_date(void),这样阳历日历的星期排法就确定了。表1:月份 1 2 3 4 5 6 7 8 9 10 11 12 闰年 31 29 31 30 31 30 31 31 30 31 30 31 非闰年 31 28 31 30 31 30 31 31 30 31 30 31 变量定义:Public:Unsigned int temp_total_day;Unsigned char gc_solar_calendar_year;Unsigned char gc_solar_calendar_month;Unsigned char gc_solar_calendar_date;Unsigned char gc_lunar_calendar_year;Unsigned char gc_lunar_calendar_month;Unsigned char gc_lunar_calendar_date;Unsigned char start_day_of_week;说明:函数get_solar_day_date(void)的输入变量:gc_solar_calendar_year和gc_solar_calendar_month输出变量:start_day_of_week和temp_total_dayVoid get_solar_day_date(void)unsigned char temp01;/*-calculate what day is the day of the current month and year. MonSun?-*/*条件初始化二次,减少运算数据量. temp_total_day 是int型变量*/start_day_of_week = 2; temp_total_day = 0;calculate_temp = 1;if(gc_solar_calendar_year 99)start_day_of_week = 6;calculate_temp = 100;for(temp01 = calculate_temp; temp01gc_solar_calendar_year; temp01+) if(temp01%4 = 0)start_day_of_week +=2;temp_total_day += 366; else start_day_of_week +=1;temp_total_day += 365;for(temp01 = 1;temp01 99)gc_lunar_calendar_year = 99;gc_lunar_calendar_month = 11;gc_lunar_calendar_date = 25;temp_total_day += 25;calculate_temp = 100;elsegc_lunar_calendar_year = 0;gc_lunar_calendar_month = 11;gc_lunar_calendar_date = 11;temp_total_day += 11;calculate_temp = 1;if(gc_solar_calendar_year calculate_temp|gc_solar_calendar_month1) for(mc_tpumenus_temp_loop = 1;mc_tpumenus_temp_loop0;)temp_total_day -=calendar_calculate_lunar_month_total_day();temp_leap_month = tpumenus_lunar_calendar_month_table2*gc_lunar_calendar_year + 1;temp_leap_month = (temp_leap_month4)&0x0F;if(gc_lunar_calendar_month = temp_leap_month)switch(gc_lunar_calendar_year)case 6,14,19,25,33,36,38,41,44,52,55,79,117,136,147,150,155,158,185,193:if(temp_total_day31)gc_lunar_calendar_date = temp_total_day;mc_tpumenus_temp_loop = 0;temp_flag = 0;else temp_total_day -= 30;break; /current month:temp_leap_monthdefault:if(temp_total_day 30)gc_lunar_calendar_date = temp_total_day;mc_tpumenus_temp_loop = 0;temp_flag = 0; /*current month:temp_leap_month*/ else temp_total_day -= 29; break; if(temp_flag)gc_lunar_calendar_month+;if(gc_lunar_calendar_month = 13)gc_lunar_calendar_month = 1;gc_lunar_calendar_year+;If(temp_total_day 60,ignore compare mc_tpumenus_temp_01 = calendar_calculate_lunar_month_total_day();if(temp_total_day (mc_tpumenus_temp_01 + 1)mc_tpumenus_temp_loop = 0;gc_lunar_calendar_date = temp_total_day; gc_lunar_leap_month = (temp_flag4)|temp_leap_month;/*set leap_month flag*/说明:函数calendar_calculate_lunar_month_total_day(void)根据输入变量gc_lunar_calendar_year和gc_lunar_calendar_month,结合压缩数据表lunar_calendar_month_table计算出对应阴历月的总的天数。unsigned char calendar_calculate_lunar_month_total_day(void)unsigned char mc_tpumenus_temp_01;unsigned char mc_tpumenus_temp_02;if(gc_lunar_calendar_month mc_tpumenus_temp_02)&0x01)return(29);else return(30);阳历日和农历节气的对应关系压缩节气数据表:根据规律可以得到四个数据表(每个阳历月有两个节气,每个节气需要两个数据表):const unsigned char calendar_solar_term_table_011233 = 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, /month 15,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, /26,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, /35,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, /46,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, /56,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, /67,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, /78,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, /88,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, /99,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, /108,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, /117,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, /12; /这个数据表表示了每个月第一个节气出现的规律const unsigned char calendar_solar_term_year_01129 = 13,49,85,117,149,185,201,250,250, /month 113,45,81,117,149,185,201,250,250, /213,48,84,112,148,184,200,201,250, /313,45,76,108,140,172,200,201,250, /413,44,72,104,132,168,200,201,250, /55 ,33,68,96 ,124,152,188,200,201, /629,57,85,120,148,176,200,201,250, /713,48,76,104,132,168,196,200,201, /825,60,88,120,148,184,200,201,250, /916,44,76,108,144,172,200,201,250, /1028,60,92,124,160,192,200,201,250, /1117,53,85,124,156,188,200,201,250, /12; /这个数据表表示了每个月第一个节气出现规律对应的阳历年份范围const unsigned char calendar_solar_term_table_021229 = 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,; /这个数据表表示了每个月第二个节气出现的规律const unsigned char calendar_solar_term_year_02128 = 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,;/这个数据表表示了每个月第二个节气出现规律对应的阳历年份范围每个阳历月对应的两个农历节气出现的日期,可根据条件规律算法,分别由以下两个函数实现:unsigned char calendar_calculate_solar_term_1(void)zpage unsigned char done_index;zpage unsigned char solar_term;done_index = 0;while(gc_solar_calendar_year = calendar_solar_term_year_01gc_solar_calendar_month - 1done_index) done_index+;solar_term = calendar_solar_term_table_01gc_solar_calendar_month - 14*done_index + gc_solar_calendar_year%4;if(gc_solar_calendar_year = 121)&(gc_solar_calendar_month = 4)solar_term = 5;if(gc_solar_calendar_year = 132)&(gc_solar_calendar_month = 4)solar_term = 5;if(gc_s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 薯类生产项目投资风险评估报告
- 物联网终端的动态防御与攻击防御能力提升-洞察阐释
- 物联网在智慧园区建设中的应用-洞察阐释
- 聚合物表面润湿性调控-洞察阐释
- 响应式建筑结构设计与环境适应性研究-洞察阐释
- 数字绘画与3D打印在传统工艺中的应用研究-洞察阐释
- 山东力明科技职业学院《生物技术制药》2023-2024学年第二学期期末试卷
- 漳州卫生职业学院《医学生人际沟通学》2023-2024学年第二学期期末试卷
- 广州城建职业学院《审计学》2023-2024学年第二学期期末试卷
- 青岛黄海学院《素描表现》2023-2024学年第二学期期末试卷
- 习近平总书记关于应急管理的重要论述
- 2025年3月10日吉林省纪委监察厅遴选面试真题及解析
- 2025年陕西省新高考语文试卷(含答案解析)
- 期末试卷(试题)(含答案)-2024-2025学年一年级下册数学北师大版
- 《编织美好》教学课件-2024-2025学年鲁教版(五四学制)(2024)初中美术六年级上册
- 2025年江西省高考物理真题
- 上海浦东新区公办学校储备教师教辅招聘笔试真题2022
- 国开(甘肃)2024年春《地域文化(专)》形考任务1-4终考答案
- 胎心监护以及判读
- 企业资产损失所得税税前扣除鉴证业务操作的指南
- 高等数学(下册)资料期末复习试题与答案
评论
0/150
提交评论