Traditional Culture Encyclopedia - Almanac inquiry - I want to design a perpetual calendar with a single chip microcomputer. How to realize the conversion from solar calendar to lunar calendar? It is best to give ideas and related procedures.
I want to design a perpetual calendar with a single chip microcomputer. How to realize the conversion from solar calendar to lunar calendar? It is best to give ideas and related procedures.
Use:
The current date calculates the lunar heavenly stems and earthly branches of this date and the animal sign of the current year.
' ## - ##
Dim goal
Dark day, Monday, Sunday, Sunday, Sunday
Set objChinaDay = New China Day
Call objChinaDay. Action ("",day, week, year, month, month, month)
Response. Write a day&"?" Current date
Response. Write for a week & "?" week
Response. Write sChinaYear & amp "?" Lunar New Year
Response. Write sChinaDay & amp "?" Lunar date
Response. Write schinaani & "?" zodiac
Copyright: This code is not original, and the original author is unknown.
'*********************************************************************************
Class China Day
dim arr week name(7),MonthAdd( 1 1),NongliData(99)
dim arrTianGan(9)、arrDiZhi( 1 1)、arrShuXiang( 1 1)、arrDayName(30)、arrMonName( 12)
Dark curTime, curYear, curMonth, curDay, curWeekday
Dim i,m,n,k,isEnd,bit,TheDate
Initialization data
Sub Class_Initialize()
-
Define the display string
Name of the week
arr week name(0)=“*“
arr week name( 1)=“Sunday“
Arr week name(2)= "Monday"
Arr week name(3)= "Tuesday"
Arr week name(4)= "Wednesday"
Arr week name(5)= "Thursday"
Arr week name(6)= "Friday"
Arr week name(7)= "Saturday"
Tiangan name
arr tiangan(0)=“A“
arretiangan( 1)=“B“
arr tiangan(2)=“c“
Arretiangan (3) = d
arr tiangan(4)=“E“
Allen Tiangan (5)= Ji
"Geng"
ArrTianGan(7)= Xin
Arretiangan (8) = "Ren"
Arigan (9)= "Deck"
Name of earthly branch
Arrdhizhi (0) = "son"
ArrDiZhi( 1)= "ugly"
ArrDiZhi(2)= Yin
Arrdhizhi (3) = gross
Arrdi zhi(4)= "Chen"
ArrDiZhi(5)=“Si”
ArrDiZhi(6)= "noon"
ArrDiZhi(7)= "No"
"God"
Arrdhizhi (9) = unitary
ArrDiZhi( 10)= "Xu"
ArrDiZhi( 1 1)= "sea"
Zodiac name
arr shuxiang(0)=“Rat”
Arr shuxiang( 1)= "Niu"
Arr shuxiang(2)= Tiger
Arr shuxiang(3)= "rabbit"
Arr shuxiang(4)= "Dragon"
ArrShuXiang(5)= "snake"
Arr shuxiang(6)= horse
Abuduxiang (7)= sheep
Arr shuxiang(8)= Monkey
Abuduxiang (9)= Chicken
Arr shuxiang( 10)= "dog"
Arr shuxiang( 1 1)= "pig"
Lunar date name
arrDayName(0)=“*“
ArrDayName( 1)= "Grade One"
Arr day name(2)= "Grade 2"
Arr day name(3)= "Grade Three"
Arr day name(4)= "Grade 4"
ArrDayName(5)= "Day 5"
ArrDayName(6)= "Day 6"
ArrDayName(7)= "Day 7"
Arrdayname (8) = "Grade 8"
ArrDayName(9)= "Day 9"
ArrDayName( 10)= "Day 10"
ArrDayName( 1 1)=“Eleven“
ArrDayName( 12)= "Twelve"
ArrDayName( 13)= "thirteen"
ArrDayName( 14)= "fourteen"
ArrDayName( 15)=“ 15“
ArrDayName( 16)= "Sixteen"
ArrDayName( 17)=“Seventeen“
ArrDayName( 18)=“ 18“
ArrDayName( 19)= "Nineteen"
Arr day name(20)= "Twenty"
ArrDayName(2 1)=“2 1“
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“
Lunar month name
arrMonName(0)=“*“
ArrMonName( 1)= "positive number"
ArrMonName(2)=“two“
ArrMonName(3)= "three"
ArrMonName(4)=“four“
ArrMonName(5)=“five“
ArrMonName(6)=“six“
ArrMonName(7)=“seven“
ArrMonName(8)= "eight"
ArrMonName(9)= "Nine"
ArrMonName( 10)= "ten"
ArrMonName( 1 1)=“Winter“
ArrMonName( 12)=“La“
-
Definition of tolerance data
Days before each month in Gregorian calendar
MonthAdd(0)= 0
MonthAdd( 1)= 3 1
MonthAdd(2)= 59
MonthAdd(3)= 90
MonthAdd(4)= 120
MonthAdd(5)= 15 1
MonthAdd(6)= 18 1
MonthAdd(7)= 2 12
MonthAdd(8)= 243
MonthAdd(9)= 273
MonthAdd( 10)= 304
MonthAdd( 1 1)= 334
Lunar data
NongliData(0)= 2635
NongliData( 1)= 333387
NongliData(2)= 170 1
NongliData(3)= 1748
NongliData(4)= 26770 1
NongliData(5)= 694
NongliData(6)= 239 1
NongliData(7)= 133423
NongliData(8)= 1 175
NongliData(9)= 396438
NongliData( 10)= 3402
NongliData( 1 1)= 3749
NongliData( 12)= 33 1 177
NongliData( 13)= 1453
NongliData( 14)= 694
NongliData( 15)= 20 1326
NongliData( 16)= 2350
NongliData( 17)= 465 197
NongliData( 18)= 322 1
NongliData( 19)= 3402
NongliData(20)= 400202
NongliData(2 1)= 290 1
NongliData(22)= 1386
NongliData(23)= 2676 1 1
NongliData(24)= 605
NongliData(25)= 2349
NongliData(26)= 1375 15
NongliData(27)= 2709
NongliData(28)= 464533
NongliData(29)= 1738
NongliData(30)= 290 1
NongliData(3 1)= 33042 1
NongliData(32)= 1242
NongliData(33)= 265 1
NongliData(34)= 199255
NongliData(35)= 1323
NongliData(36)= 529706
NongliData(37)= 3733
NongliData(38)= 1706
NongliData(39)= 398762
NongliData(40)= 274 1
NongliData(4 1)= 1206
NongliData(42)= 267438
NongliData(43)= 2647
NongliData(44)= 13 18
NongliData(45)= 204070
NongliData(46)= 3477
NongliData(47)= 46 1653
NongliData(48)= 1386
NongliData(49)= 24 13
NongliData(50)= 330077
NongliData(5 1)= 1 197
NongliData(52)= 2637
NongliData(53)= 268877
NongliData(54)= 3365
NongliData(55)= 53 1 109
NongliData(56)= 2900
NongliData(57)= 2922
NongliData(58)= 398042
NongliData(59)= 2395
NongliData(60)= 1 179
NongliData(6 1)= 2674 15
NongliData(62)= 2635
NongliData(63)= 66 1067
NongliData(64)= 170 1
NongliData(65)= 1748
NongliData(66)= 398772
NongliData(67)= 2742
NongliData(68)= 239 1
NongliData(69)= 33003 1
NongliData(70)= 1 175
NongliData(7 1)= 16 1 1
NongliData(72)= 2000 10
NongliData(73)= 3749
NongliData(74)= 5277 17
NongliData(75)= 1452
NongliData(76)= 2742
NongliData(77)= 332397
NongliData(78)= 2350
NongliData(79)= 3222
NongliData(80)= 268949
NongliData(8 1)= 3402
NongliData(82)= 3493
NongliData(83)= 133973
NongliData(84)= 1386
NongliData(85)= 4642 19
NongliData(86)= 605
NongliData(87)= 2349
NongliData(88)= 334 123
NongliData(89)= 2709
NongliData(90)= 2890
NongliData(9 1)= 267946
NongliData(92)= 2773
NongliData(93)= 592565
NongliData(94)= 12 10
NongliData(95)= 265 1
NongliData(96)= 395863
NongliData(97)= 1323
NongliData(98)= 2707
NongliData(99)= 265877
End joint
'#################################################################
Main method operation
Enter the date. If you do not enter it, it will default to the current date.
SDay Chinese format date
What day is it today?
Lunar New Year of Happiness and Ugliness
SChinaDay lunar calendar day
Sinnani is an animal sign.
'#################################################################
Public Function Action (Day, Day, Week, Year, Day, Day)
Convert the date to be converted
If inDay= ""or not a date (inDay), then
Get the current system time
curTime = Now()
other
curTime = CDate(inDay)
If ... it will be over.
if Datediff(“d“,curTime,Cdate(“ 192 1-2-8“))& gt; Then 0
Exit function
If ... it will be over.
Generate the current Gregorian calendar year, month and day = = & gtsDay
cur Year = Year(curTime)
CurMonth = month (curTime)
curDay = Day(curTime)
Sday = curyear & "year"
if(cur month & lt; 10)
SDay = sDay & amp“0 "and Ke Yue & "Moon"
other
Sday = sday & Keyue & "the moon"
If ... it will be over.
if(curDay & lt; 10)
SDay = sDay & amp“0 "and Kede Day&"Day "
other
Sday = sday & Kede Day&"Day"
If ... it will be over.
Generate the current Gregorian calendar week = => Sweeping Day
CurWeekday = working day (curTime)
sweek day = arrWeekName(cur weekday)
Days from the initial time of 192 1 February 8th: 192 1-2-8 (the first day of the first month).
the date =(cur year- 192 1)* 365+Int((cur year- 192 1)+curDay+MonthAdd(cur month- 1)-38
If((cur year Mod 4)= 0 and curMonth & gt Then what?
Date = date+1
If ... it will be over.
Calculate the heavenly stems, earthly branches, months and days of the lunar calendar.
isEnd = 0
m = 0
-
do
if(NongliData(m)& lt; Then 4095
k = 1 1
other
k = 12
If ... it will be over.
n = k
-
do
if(n & lt; 0) Then
Quit Do
If ... it will be over.
Gets the value of the nth binary bit of NongliData(m)
bit = NongliData(m)
For i = 1 to n steps 1
bit = Int(bit/2)
then
Bit = Bit Module 2
if(the date & lt; = 29+bits) Then
isEnd = 1
Quit Do
If ... it will be over.
Date = Date-29 digits
n = n - 1
ring
-
If (isEnd = 1), then
Quit Do
If ... it will be over.
m = m + 1
ring
-
curYear = 192 1 + m
curMonth = k - n + 1
CurDay = date
If (k = 12) then
If (Curmonth = (int (nonglidata (m)/65536)+1), then
Month = 1-month
else if(cur month & gt; (int (nonglidata (m)/65536)+1) and then
curMonth = curMonth - 1
If ... it will be over.
If ... it will be over.
Heavenly stems and earthly branches that generates the lunar calendar = => Xi Nayir.
SChinaYear =“Lunar New Year“& amp; arrTianGan((cur Year-4)Mod 60)Mod 10); arrDiZhi(((curYear-4)Mod 60)Mod 12); "year"
Generating Animal Constellation = = "Sinani"
schina ni = arr shuxiang((cur year-4)Mod 60)Mod 12)
Generate lunar month and day = = "; NongliDayStr
if(cur month & lt; 1)
SChinaDay =“leap“&; arrMonName(- 1 * cur month)
other
sChinaDay = arrMonName(cur month)
If ... it will be over.
Schinaday = schinaday & "the moon"
sChinaDay = sChinaDay & amparr day name(curDay)
End function
End class
% & gt
- Previous article:Calendar should avoid 202 1.
- Next article:Laohuangli renting house Jiri
- Related articles
- Zodiac auspicious day 2019 65438+10.21Gregorian calendar query?
- Is it appropriate to move from the summer solstice of the Year of the Tiger in 2022? How about entering the new house?
- Zodiac today's fortune query yellow calendar
- Is it dangerous for Tik Tok to chat with strangers?
- I dreamed that I was lucky to play mahjong, and others would give me money.
- What day is beginning of spring 1982?
- Lunar calendar zodiac auspicious day 55
- How to name a boy born on May 7, 2020 and a mouse baby?
- Auspicious day of the zodiac: 2065438+April 2008, the auspicious day for children.
- Is March 29th of the 2022 lunar calendar suitable for marriage? Is today a good day?