Traditional Culture Encyclopedia - The 24 Solar Terms - Algorithm of converting solar calendar into lunar calendar
Algorithm of converting solar calendar into lunar calendar
It is impossible to use a simple formula instead of using a lot of data like a perpetual calendar (although it can be simplified) to achieve the purpose of conversion between public and lunar calendar. All the software that we can see to convert Gregorian calendar into lunar calendar contains calendar data of different years.
Among these data, the most important is the number of days in each month of the lunar calendar. Because the lunar calendar is a lunar calendar, the part of the lunar calendar (according to the phase of the moon) determines a certain day in a month, and the part of the solar calendar (according to the height of the sun) is a solar term. Solar terms basically correspond directly to the Gregorian calendar, which is easy to calculate; However, the relationship between the moon phase period and the earth's revolution is relatively complicated, and generally requires astronomical observation data to give the time, so there is no simple formula for whether a lunar month is a big moon or a small moon.
As for the leap between the Gregorian calendar and the lunar calendar, there is a certain calculation method, which is not difficult.
If it is only astronomical data, it can still be counted-because the astronomical period is very stable, we only need to calculate it strictly according to the astronomical period. But there is another troublesome point, that is, the solar calendar and the lunar calendar are not strictly in accordance with the actual astronomical cycle, and there are many human factors. The most famous is that the Roman emperor revised the length of February and August for many times. Due to inaccurate calculation, the 10th was artificially deleted from julian calendar. In China, the calendar published by * * * is inconsistent with the astronomical phenomena because the ancient astronomical observations are inaccurate (we can't demand the accuracy of ancient observations). Therefore, these two calendars are related to a period of society, so there is no certain law to follow.
The comparison table for converting the lunar calendar into the Gregorian calendar is Gregorian calendar1Sunday, April 29th, 945.
How are the lunar calendar and Gregorian calendar converted? (how to calculate? ) Do you calculate by mouth or by pen?
I'm telling you, this is unreliable, it can't be calculated at all, and the transformation involved is not a simple formula. On the contrary, its transformation is quite complicated.
If you are interested in writing programs, I can provide a library of conversion functions. You can realize the conversion between the lunar calendar and the Gregorian calendar by calling a function.
At present, I have realized the transformation perfectly, and I can provide it if necessary.
What is the algorithm for converting dates into lunar calendar? Excel solar calendar to lunar calendar method 1: use text function. Column A is the Gregorian calendar date, so we enter the formula in cell B 1: = text (A 1, [$- 130000] YYY year, m month &; If (len (-text (a 1,[$- 130000] DD)) = 1,Chu,)&; D), drop down to complete the conversion from Gregorian calendar to lunar calendar.
How does excel convert solar calendar formula from lunar calendar? For example, today is September 2, 20 10, and the following formula can be used to get July 24 of the lunar calendar:
Although the result is a bit unsatisfactory when encountering a leap month, as shown in the following figure, February 9 of the 20th10 of the lunar calendar should be1February 26, but there was a leap month that year, so there was an innocent month. But it's much faster than coding, and leap months don't happen every day.
If the formula is changed to =MID (methyl, ethyl, propyl, butyl, hexyl, octyl, non-undecyl, mod (text (a2, [$- 130000] e)-4,10)+1)&; MID (Zi Chou Mao Yinchen asked for a letter at noon), mod (text (a2, [$- 130000] e)-4, 12)+ 1,1)&; year & Text(a2,[$- 130000][DBM num 1]m month)&; Text (A2, if (-text (A2, [$- 130000] d) = 10, the tenth day, if (-text (A2, [$-130000] d) >/kloc-0.
The realization of the algorithm from solar calendar to lunar calendar The following is a lunar calendar algorithm about VB.
Date data is defined as follows
The first 12 bytes mean that 1- 12 is a big month or a small month, 1 is a big month of 30 days, and 0 is a small month of 29 days;
13 is a leap month, 1 is a big month with 30 days, and 0 is a small month with 29 days;
The number 14 is the month of leap month. If it is not a leap month, it is 0, otherwise the month is given. 10, 1 1 and 12 are denoted by a, b and c respectively, that is, the basic system of 16 is used.
The last four digits are the date of the Lunar New Year, that is, the date of the Gregorian calendar 65438+ 10 1, for example, 01stands for 65438+ 10/3 1.
The function getchgdate (byval v date is a string and byval chg type is a conversion mode) is a string.
dim vvdate()As String = Split(vDate,-)
If vvdate(0)> 0;) > 0; 20 1 1 or vvdate(0) >
How to calculate the conversion formula between lunar calendar and solar calendar
1, solar calendar date calculation method of lunar calendar date:
As mentioned above, the date of the lunar calendar is based on the full moon, and each new moon is the first day. The full moon is 15 (the 16th month) and the dark month is 29 (the 30th month).
If you want to know what June 8th is, 1984? We can use the formula to calculate the date of the lunar calendar: for example, the number of years-1977 (or1901) = 4q+r.
Then: lunar date =14q+10.6 (r+1)+date ordinal number of a year -29.5n (note: in the formula, q, r and n are all natural numbers, r >;;
How to convert Gregorian calendar into lunar dimweek name (7), monthly addition (1 1), nonglidata (99), heavenly stems (9), earthly branches (1 1) and book fragrance (160) in EXCEL?
Dim curTime、curYear、curMonth、curDay、curWeekday
Dim GongliStr,WeekdayStr,NongliStr,NongliDayStr
Dim i,m,n,k,isEnd,bit,TheDate
Private Sub-Form _Load ()
Get the current system time
curTime = Now()
Name of the week
WeekName(0) = *
Day Name (1) = Sunday
WeekName(2) = Monday
WeekName(3) = Tuesday
WeekName(4) = Wednesday
WeekName(5) = Thursday
WeekName(6) = Friday
WeekName(7) = Saturday
Tianganming
Tiangan (0) = a.
Tiangan (1) = b.
Tiangan (2) = C.
Tiangan (3) = d
Tiangan (4) = E
Heavenly stems (5) = self-nature
Tiangan (6) = Geng
Tiangan (7) = Xin
Tiangan (8) = Ren
Tiangan (9) = decyl
Name of earthly branch
DiZhi(0) = child
Di Zhi (1) = Ugly
Ground straight (2) = Yin
Di Zhi ③ = Mao
Di Zhi (4) = Chen
Ground level (5) = Si
Ground straight (6) = noon
Di Zhi (7) = No.
Di Zhi (8) = Shen
Ground straight (9) = unitary
Vertical (10) = 0
Di Zhi (1 1) = sea
Animal constellation name
Shuxiang (0) = mouse
Shuxiang (1) = Niu
Shuxiang (2) = Tiger
Shuxiang (3) = Rabbit
Shuxiang (4) = Dragon
Shuxiang (5) = Snake
Shuxiang (6) = Ma
Shuxiang (7) = sheep
Shuxiang (8) = Monkey
Shuxiang (9) = Chicken
Shuxiang (10) =&; q......& gt& gt
How to convert the lunar calendar into the solar calendar, and find the algorithm int lunarInfo[]={/* lunar data */
0x04bd8,0x04ae0,0570,0x054d5,0x0d260,0x0d950,0x 16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,05b6,04d0,0x0d250,0x 1d255,0x0b540,0x0d6a0,0da2,0x095b0,0x 14977,
0x04970,04b0,0x0b4b5,0x06a50,0x06d40,0x 1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x 186e3,0x092e0,0x 1c8d7,0x0c950,
0x0d4a0,0x 1d8a6,0x0b550,0x056a0,0x 1a5b4,0x025d0,0x092d0,0x0d2b2,0950,0x0b557,
0x06ca0,0x0b550,0x 15355,0x04da0,05d0,0x 14573,0x052d0,09a8,0x0e950,0x06aa0,
0ea6,0b50,0x04b60,0ae4,0570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,04d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x 195a6,
0x095b0,0x049b0,0974,04b0,0x0b27a,0x06a50,0x06d40,0f46,0b60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0b60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0bb7,0x025d0,0x092d0,0x0cab5,
0950,0x0b4a0,0x 0ba 4,0d50,0x055d9,0x04ba0,05b0,0x 15 176,0x052b0,0930,
0x07954,0x06aa0,0d50,0x05b52,0x04b60,06e6,04e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,04d0,0x 1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0577,04b0,0a50,0x 1b255,0x06d20,0da 0 };
int solarMonth[]={3 1,28,3 1,30,3 1,30,3 1,30,3 1,30,3 1 };
-
int y yeardays(int y){
int i,sum = 348
for(I = 0x 8000; I & gt0x8 I>> =1) sum+= (lunarinfo [y-190 ...>>.
- Previous article:When is the potato planting season?
- Next article:Can you see the observation guide of annular eclipse on the day of summer solstice?
- Related articles
- Twenty-four solar terms guess solar terms
- There is a saying in China that "see summer in the long summer".
- The way to keep healthy in solar terms
- How many revolutions does pentium x40 idle normally?
- There is a poem of five in the middle.
- How many days are there in summer solar terms?
- The traditional custom of mango solar terms?
- I want 500-600 words of Tomb-Sweeping Day's manuscript.
- Will there be a hint that the community correction clock is not in the jurisdiction?
- A synonym for Mid-Autumn Festival