本文目录一览:
一招教会你公历换算成农历,要不要试试看
古代的历法是干支纪年,俗称农历或阴历,现在我们都统一采用公历的阿拉伯数字纪年。因此,就存在着一个历法的换算问题。当然,我们可以查历书就直接知道了,但是这个方法并不一定方便。现在告诉大家一个简单的口诀,大家根据这个口诀,再进行简单的推算,就能很快地将公历的数字年,换算成阴历的干支年。
在干支纪年中,由于天干是十位,刚好是十进制,因此,每十年的相应位上,天干都是相同的,比如1980年、1970年、1960年的天干都是庚,而1981年、1971年、1961年的天干都是辛,以此类推,我们只要记住从1至10位的不同天干就行了,不必再做什么推算。要推算的是地支,地支是十二位,不是十进制,比较麻烦。但我们只要记住每个0位年的地支,还是可以方便的推算出每一年的地支。
我们现在暂从本世纪的1900年为始,1900年到现在已经86年了,我们所看到的病号大概都在这个范围以内,只有极少数的超过这个范围。现在需要记忆一个0位年上的地支次第口诀,就是子戌申午辰寅。1900年,它的地支是子,天干为庚,即庚子年,1910年,它的地支是戌,天干一样还是庚,即庚戌年,依次1920年为庚申年,1930年为庚午年,1940年为庚辰年,1950年为庚寅年。
寅以后,上述的口诀再重新开始,即1960年又为庚子年,1970年为庚戌年,1980年为庚申年,1990年为庚午年,以此类推,无有穷尽。知道了每个0位年的地支,就可以从相近的两个0位年推出尾数为1、2、3、4、5、6、7、8、9这些年的地支。
我们任举一年,1954年的干支是什么?先定天干,我们已经知道0位数的天干是庚,那么,依次而推,1是辛、2是壬、3是癸、4是甲、5是乙、6是丙、7是丁、8是戊、9是己,所以54年的天干是甲。由上述的口诀,我们已经知道,1950年的地支是寅。那么,依次而推,1951年是卯、1952年是辰、1953年是巳、1954年是午。
因此,1954年的干支就是甲午,1955年是乙未,1956年是丙申,1957年是丁酉,1958年是戊戌,1959年是己亥。
再推一个,1978年的干支,8位上的天干我们已经知道,不用再推算,8是戊。现在看地支,按照地支口诀,1950年是寅年,1960年重新开始子戌申午辰寅的次序,那么,1960年是子,1970年是戌,1980年是申,1990年是午,1978年离1980年近。
我们选从1980年来推算,1980年的干支是庚申,往前推一位,1979年是己未,1978年就是戊午。通过口诀反复演练熟能生巧,学会这个方法会给您以后的生活带来很大便利。
农历转公历
Public Function LTG(Optional xx_date As Date, Optional irow As Integer) '农历转公历
Dim LunarYear, LunarMonth, LunarDay
Dim NongliData(100)
'农历数据
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
NongliData(100) = 1706
Dim m, monthCount, toCurMonthCnt, LeapMonth, theDate, curTime
Dim i1, i2, i3, bit
'获取当前变量日期
curTime = xx_date
'LunarYear = Year(curTime)
LunarYear = Year(Now())
LunarMonth = Month(curTime)
LunarDay = Day(curTime)
m = LunarYear - 1921
monthCount = 0
toCurMonthCnt = 0
LeapMonth = -1
theDate = LunarDay - 1
For i1 = 0 To m - 1 Step 1
If (NongliData(i1) < 4095) Then
monthCount = 11
Else
monthCount = 12
End If
For i2 = 0 To monthCount Step 1
bit = NongliData(i1)
For i3 = 1 To i2 Step 1
bit = Int(bit / 2)
Next
bit = bit Mod 2
theDate = theDate + 29 + bit
Next
Next
If (NongliData(m) < 4095) Then
monthCount = 11
toCurMonthCnt = monthCount - LunarMonth + 2
Else
monthCount = 12
toCurMonthCnt = monthCount - LunarMonth + 1
LeapMonth = Int(NongliData(m) / 65536)
If LunarMonth <= LeapMonth Then toCurMonthCnt = toCurMonthCnt + 1
End If
For i2 = monthCount To toCurMonthCnt Step -1
bit = NongliData(m)
For i3 = 1 To i2 Step 1
bit = Int(bit / 2)
Next
bit = bit Mod 2
theDate = theDate + 29 + bit
Next
LTG = DateAdd("d", theDate, "1921/2/8")
If irow = 1 Then
Sheet1.Cells(1, 10) = "'" & LTG
Else
Sheet1.Cells(irow, 4) = "'" & LTG
End If
End Function
Private Sub CommandButton1_Click()
If IsDate(Sheet1.Cells(1, 9)) = True And IsNull(Sheet1.Cells(1, 9)) = False And Sheet1.Cells(1, 9) <> "" Then
aaa = LTG(Sheet1.Cells(1, 9), 1)
End If
Dim i As Integer
For i = 2 To 100
Sheet1.Cells(i, 4) = ""
If Sheet1.Cells(i, 2) <> "" And IsNull(Sheet1.Cells(i, 2)) = False And IsDate(Sheet1.Cells(i, 2)) = True Then
If Sheet1.Cells(i, 3) = "Y" Then
bbb = LTG(Sheet1.Cells(i, 2), i)
Else
Sheet1.Cells(i, 4) = "'" & Sheet1.Cells(i, 2)
End If
Else
Application.DisplayAlerts = False
Application.Quit
End If
Next i
End Sub