我想用单片机设计一个万年历,如何实现阳历到阴历的转换?最好给出思路和相关程序。
使用:
当前日期计算该日期的农历天干地支和当前年份的属相。
' ## - ##
暗淡的目标
昏暗日,周一,周日,周日,周日
Set objChinaDay =新中国日
打电话给objChinaDay。行动(““,日,周,年,月,月,月)
回应。写日& amp"?"当前日期
回应。写一周& amp"?"周
回应。写sChinaYear & amp"?"农历年
回应。写sChinaDay & amp"?"农历日期
回应。写sChinaAni & amp"?"黄道带
版权说明:本代码非原创,原作者不详。
'*********************************************************************************
班级中国日
dim arr week name(7),MonthAdd(11),NongliData(99)
dim arrTianGan(9)、arrDiZhi(11)、arrShuXiang(11)、arrDayName(30)、arrMonName(12)
昏暗的curTime、curYear、curMonth、curDay、curWeekday
Dim i,m,n,k,isEnd,bit,TheDate
初始化数据
Sub Class_Initialize()
-
定义显示字符串
本周名称
arr week name(0)=“*“
arr week name(1)=“Sunday“
arr week name(2)=“星期一“
arr week name(3)=“星期二“
arr week name(4)=“星期三“
arr week name(5)=“星期四“
arr week name(6)=“星期五“
arr week name(7)=“星期六“
天干名称
arr tiangan(0)=“A“
arretiangan(1)=“B“
arr tiangan(2)=“c“
ArrTianGan(3)=丁
arr tiangan(4)=“E“
阿伦天干(5)=纪
“更”
ArrTianGan(7)= Xin
ArrTianGan(8)=“壬”
阿日干(9)=“癸”
地支名称
ArrDiZhi(0)=“儿子“
ArrDiZhi(1)=“丑陋“
ArrDiZhi(2)= Yin
ArrDiZhi(3)=毛
arrdi zhi(4)=“陈”
ArrDiZhi(5)=“Si”
ArrDiZhi(6)=“正午”
ArrDiZhi(7)=“不是”
“神”
ArrDiZhi(9)=酉
ArrDiZhi(10)=“徐“
ArrDiZhi(11)=“海”
属相名称
arr shuxiang(0)=“Rat”
arr shuxiang(1)=“牛”
arr shuxiang(2)=老虎
arr shuxiang(3)=“兔子”
arr shuxiang(4)=“龙”
ArrShuXiang(5)=“蛇”
arr shuxiang(6)=马
阿不都香(7)=羊
arr shuxiang(8)=猴子
阿不都香(9)=鸡
arr shuxiang(10)=“狗“
arr shuxiang(11)=“猪”
农历日期名称
arrDayName(0)=“*“
ArrDayName(1)=“一年级”
arr day name(2)=“等级2“
arr day name(3)=“三年级”
arr day name(4)=“等级4“
ArrDayName(5)=“第五天“
ArrDayName(6)=“第六天“
ArrDayName(7)=“第七天“
arr day name(8)=“8级“
ArrDayName(9)=“第九天“
ArrDayName(10)=“第10天“
ArrDayName(11)=“Eleven“
ArrDayName(12)=“十二“
ArrDayName(13)=“十三“
ArrDayName(14)=“十四“
ArrDayName(15)=“15“
ArrDayName(16)=“十六“
ArrDayName(17)=“Seventeen“
ArrDayName(18)=“18“
ArrDayName(19)=“十九“
arr day name(20)=“二十“
ArrDayName(21)=“21“
ArrDayName(22)=“22“
ArrDayName(23)=“23“
ArrDayName(24)=“24“
ArrDayName(25)=“25“
ArrDayName(26)=“26“
ArrDayName(27)=“27“
ArrDayName(28)=“28“
ArrDayName(29)=“29“
ArrDayName(30)=“30“
农历月份名称
arrMonName(0)=“*“
ArrMonName(1)=“正数“
ArrMonName(2)=“two“
ArrMonName(3)=“三“
ArrMonName(4)=“four“
ArrMonName(5)=“five“
ArrMonName(6)=“six“
ArrMonName(7)=“seven“
ArrMonName(8)=“八“
ArrMonName(9)=“九“
ArrMonName(10)=“十“
ArrMonName(11)=“Winter“
ArrMonName(12)=“La“
-
公差数据的定义
公历中每个月前的天数
MonthAdd(0)= 0
MonthAdd(1)= 31
MonthAdd(2)= 59
MonthAdd(3)= 90
MonthAdd(4)= 120
MonthAdd(5)= 151
MonthAdd(6)= 181
MonthAdd(7)= 212
MonthAdd(8)= 243
MonthAdd(9)= 273
MonthAdd(10)= 304
MonthAdd(11)= 334
月球数据
NongliData(0)= 2635
NongliData(1)= 333387
NongliData(2)= 1701
NongliData(3)= 1748
NongliData(4)= 267701
NongliData(5)= 694
NongliData(6)= 2391
NongliData(7)= 133423
NongliData(8)= 1175
NongliData(9)= 396438
NongliData(10)= 3402
NongliData(11)= 3749
NongliData(12)= 331177
NongliData(13)= 1453
NongliData(14)= 694
NongliData(15)= 201326
NongliData(16)= 2350
NongliData(17)= 465197
NongliData(18)= 3221
NongliData(19)= 3402
NongliData(20)= 400202
NongliData(21)= 2901
NongliData(22)= 1386
NongliData(23)= 267611
NongliData(24)= 605
NongliData(25)= 2349
NongliData(26)= 137515
NongliData(27)= 2709
NongliData(28)= 464533
NongliData(29)= 1738
NongliData(30)= 2901
NongliData(31)= 330421
NongliData(32)= 1242
NongliData(33)= 2651
NongliData(34)= 199255
NongliData(35)= 1323
NongliData(36)= 529706
NongliData(37)= 3733
NongliData(38)= 1706
NongliData(39)= 398762
NongliData(40)= 2741
NongliData(41)= 1206
NongliData(42)= 267438
NongliData(43)= 2647
NongliData(44)= 1318
NongliData(45)= 204070
NongliData(46)= 3477
NongliData(47)= 461653
NongliData(48)= 1386
NongliData(49)= 2413
NongliData(50)= 330077
NongliData(51)= 1197
NongliData(52)= 2637
NongliData(53)= 268877
NongliData(54)= 3365
NongliData(55)= 531109
NongliData(56)= 2900
NongliData(57)= 2922
NongliData(58)= 398042
NongliData(59)= 2395
NongliData(60)= 1179
NongliData(61)= 267415
NongliData(62)= 2635
NongliData(63)= 661067
NongliData(64)= 1701
NongliData(65)= 1748
NongliData(66)= 398772
NongliData(67)= 2742
NongliData(68)= 2391
NongliData(69)= 330031
NongliData(70)= 1175
NongliData(71)= 1611
NongliData(72)= 200010
NongliData(73)= 3749
NongliData(74)= 527717
NongliData(75)= 1452
NongliData(76)= 2742
NongliData(77)= 332397
NongliData(78)= 2350
NongliData(79)= 3222
NongliData(80)= 268949
NongliData(81)= 3402
NongliData(82)= 3493
NongliData(83)= 133973
NongliData(84)= 1386
NongliData(85)= 464219
NongliData(86)= 605
NongliData(87)= 2349
NongliData(88)= 334123
NongliData(89)= 2709
NongliData(90)= 2890
NongliData(91)= 267946
NongliData(92)= 2773
NongliData(93)= 592565
NongliData(94)= 1210
NongliData(95)= 2651
NongliData(96)= 395863
NongliData(97)= 1323
NongliData(98)= 2707
NongliData(99)= 265877
末端接头
'#################################################################
主要方法操作
输入日期。如果不输入,它将默认为当前日期。
SDay中文格式日期
今天是星期几
农历辛丑年
SChinaDay阴历日
辛纳尼是一个属相。
'#################################################################
公共职能行动(日、日、周、年、日、日)
转换要转换的日期
如果inDay=““或不是日期(inDay),则
获取当前系统时间
curTime = Now()
其他
curTime = CDate(inDay)
如果…就会结束
if Datediff(“d“,curTime,Cdate(“1921-2-8“))& gt;那就0
退出功能
如果…就会结束
生成当前公历年、月、日= = & gtsDay
cur Year = Year(curTime)
curMonth =月(curTime)
curDay = Day(curTime)
sDay = curYear & amp“年份”
if(cur month & lt;10)
sDay = sDay & amp“0”和柯月&。“月亮”
其他
sDay = sDay & amp柯月&。“月亮”
如果…就会结束
if(curDay & lt;10)
sDay = sDay & amp“0”和柯德日& amp“日”
其他
sDay = sDay & amp柯德日& amp“日”
如果…就会结束
生成当前公历周= = & gt横扫日
curWeekday =工作日(curTime)
sweek day = arrWeekName(cur weekday)
从1921的初始时间算起的天数2月8日:1921-2-8(正月初一)。
the date =(cur year-1921)* 365+Int((cur year-1921)+curDay+MonthAdd(cur month-1)-38
if((cur year Mod 4)= 0且curMonth & gt然后呢
日期=日期+ 1
如果…就会结束
计算农历的天干、地支、月和日。
isEnd = 0
m = 0
-
做
if(NongliData(m)& lt;然后是4095
k = 11
其他
k = 12
如果…就会结束
n = k
-
做
if(n & lt;0)然后
退出Do
如果…就会结束
获取NongliData(m)的第n个二进制位的值
bit = NongliData(m)
对于i = 1到n步1
bit = Int(bit/2)
然后
位=位模块2
if(the date & lt;= 29 +位)那么
isEnd = 1
退出Do
如果…就会结束
日期=日期- 29位
n = n - 1
环
-
如果(isEnd = 1),则
退出Do
如果…就会结束
m = m + 1
环
-
curYear = 1921 + m
curMonth = k - n + 1
curDay =日期
如果(k = 12)那么
如果(cur month =(Int(NongliData(m)/65536)+1),则
月份= 1 -月份
else if(cur month & gt;(Int(NongliData(m)/65536)+1)然后
curMonth = curMonth - 1
如果…就会结束
如果…就会结束
生成农历的天干地支= = & gt希纳耶尔
SChinaYear =“Lunar New Year“& amp;arrTianGan((cur Year-4)Mod 60)Mod 10);arrDiZhi(((curYear-4)Mod 60)Mod 12);“年份”
生成动物星座==》辛纳尼
schina ni = arr shuxiang((cur year-4)Mod 60)Mod 12)
生成农历月和日= =》;NongliDayStr
if(cur month & lt;1)
SChinaDay =“leap“&;arrMonName(-1 * cur month)
其他
sChinaDay = arrMonName(cur month)
如果…就会结束
sChinaDay = sChinaDay & amp“月亮”
sChinaDay = sChinaDay & amparr day name(curDay)
结束功能
结束类
% & gt