农历,也称农民历、阴历或夏历,是中国传统的历法系统,其起源可以追溯到古代的农业社会。农历主要依据农时、月相和太阳运行来确定日期。
农历的起源和演变是一个复杂而持续的过程。在中国历史的不同时期,农历经历了多次改革和调整,以适应社会和农业变化。
农历的起源最早可以追溯到商朝时期。据历史记载,商朝时期的统治者意识到农事活动和天象的关联性,以太阳年和月相周期为基础,制定了最早的农历。这主要是为了农业生产活动的安排和农作物的种植、收获等重要节点的确定。
在春秋战国时期(公元前770年-公元前221年),古代中国人对太阳、月亮和星象的观察和研究逐渐增多。这个时期的学者们开始注重记录观测数据和编制日历以辅助农事和宗教活动。其中,鲁国的孔子在《春秋书》中首次提到了节气的概念,为日后的节气制定奠定了基础。
到了汉朝(公元前206年-公元220年),农历经历了重大的改革和发展。汉武帝时期,制定了较为完整的夏历系统,将二十四节气的概念引入了正式的日历中。在东汉末年,张衡发明了世界上最早的地动仪,用于观测天体运行,为农历的精确计算提供了重要的工具。
随着时间的推移,农历在唐朝(618年-907年)时达到了相对完善的程度。唐代的玄奘法师和裴松之等学者对农历进行了深入研究和改进,制定了严格的闰年规则,提高了农历的准确性。
随着现代科学技术的发展,农历在20世纪逐渐被公历所取代。在1949年中华人民共和国成立后,中国宣布采用公历作为官方日历,但农历仍然在传统节日和农业活动中继续使用。
农历通过长时间的发展,逐渐成为了一个完善的系统,包括天干、地支、二十四节气等元素。天干是指用十天干(甲、乙、丙、丁、戊、己、庚、辛、壬、癸)来表示年份的元素,地支是以十二地支(子、丑、寅、卯、辰、巳、午、未、申、酉、戌、亥)表示年份、月份和时辰的元素。二十四节气则是根据太阳在黄道上的位置,把一年分为二十四个等长的时期,用于农事活动和天文观测。
农历在中国及其周边地区广泛应用,并在社会、文化和宗教方面发挥着重要作用。尽管现代社会已普遍使用公历,但农历仍然在一些传统节日的确定和庆祝、农业生产和农民活动的安排以及民俗习惯中扮演着重要的角色。农历的起源和发展,反映了中国古代人民对天文观测、农业生产和社会生活的认识和探索。
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