真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net農(nóng)歷轉(zhuǎn)日歷 vb 農(nóng)歷

求vb的陽(yáng)歷轉(zhuǎn)農(nóng)歷的函數(shù)

我在網(wǎng)上給你百度的:

臨海ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書(shū)合作)期待與您的合作!

Public Function NongLi(Optional XX_DATE As Date)

Dim MonthAdd(11), NongliData(99), TianGan(9), DiZhi(11), ShuXiang(11), DayName(30), MonName(12)

Dim curTime, curYear, curMonth, curDay

Dim GongliStr, NongliStr, NongliDayStr

Dim i, m, n, k, isEnd, bit, TheDate

'獲取當(dāng)前系統(tǒng)時(shí)間

curTime = XX_DATE

'天干名稱

TianGan(0) = "甲"

TianGan(1) = "乙"

TianGan(2) = "丙"

TianGan(3) = "丁"

TianGan(4) = "戊"

TianGan(5) = "己"

TianGan(6) = "庚"

TianGan(7) = "辛"

TianGan(8) = "壬"

TianGan(9) = "癸"

'地支名稱

DiZhi(0) = "子"

DiZhi(1) = "丑"

DiZhi(2) = "寅"

DiZhi(3) = "卯"

DiZhi(4) = "辰"

DiZhi(5) = "巳"

DiZhi(6) = "午"

DiZhi(7) = "未"

DiZhi(8) = "申"

DiZhi(9) = "酉"

DiZhi(10) = "戌"

DiZhi(11) = "亥"

'屬相名稱

ShuXiang(0) = "鼠"

ShuXiang(1) = "牛"

ShuXiang(2) = "虎"

ShuXiang(3) = "兔"

ShuXiang(4) = "龍"

ShuXiang(5) = "蛇"

ShuXiang(6) = "馬"

ShuXiang(7) = "羊"

ShuXiang(8) = "猴"

ShuXiang(9) = "雞"

ShuXiang(10) = "狗"

ShuXiang(11) = "豬"

'農(nóng)歷日期名

DayName(0) = "*"

DayName(1) = "初一"

DayName(2) = "初二"

DayName(3) = "初三"

DayName(4) = "初四"

DayName(5) = "初五"

DayName(6) = "初六"

DayName(7) = "初七"

DayName(8) = "初八"

DayName(9) = "初九"

DayName(10) = "初十"

DayName(11) = "十一"

DayName(12) = "十二"

DayName(13) = "十三"

DayName(14) = "十四"

DayName(15) = "十五"

DayName(16) = "十六"

DayName(17) = "十七"

DayName(18) = "十八"

DayName(19) = "十九"

DayName(20) = "二十"

DayName(21) = "廿一"

DayName(22) = "廿二"

DayName(23) = "廿三"

DayName(24) = "廿四"

DayName(25) = "廿五"

DayName(26) = "廿六"

DayName(27) = "廿七"

DayName(28) = "廿八"

DayName(29) = "廿九"

DayName(30) = "三十"

'農(nóng)歷月份名

MonName(0) = "*"

MonName(1) = "正"

MonName(2) = "二"

MonName(3) = "三"

MonName(4) = "四"

MonName(5) = "五"

MonName(6) = "六"

MonName(7) = "七"

MonName(8) = "八"

MonName(9) = "九"

MonName(10) = "十"

MonName(11) = "十一"

MonName(12) = "臘"

'公歷每月前面的天數(shù)

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

'農(nóng)歷數(shù)據(jù)

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

'生成當(dāng)前公歷年、月、日 ==

GongliStr

curYear = Year(curTime)

curMonth = Month(curTime)

curDay = Day(curTime)

GongliStr = curYear "年"

If (curMonth 10)

Then

GongliStr = GongliStr "0" curMonth "月"

Else

GongliStr = GongliStr curMonth "月"

End If

If (curDay 10)

Then

GongliStr = GongliStr "0" curDay "日"

Else

GongliStr = GongliStr curDay "日"

End If

'計(jì)算到初始時(shí)間1921年2月8日的天數(shù):1921-2-8(正月初一)

TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd(curMonth - 1) - 38

If ((curYear Mod 4) = 0 And curMonth 2)

Then

TheDate = TheDate + 1

End If

'計(jì)算農(nóng)歷天干、地支、月、日

isEnd = 0

m = 0

Do

If (NongliData(m) 4095)

Then

k = 11

Else

k = 12

End If

n = k

Do

If (n 0) Then

Exit Do

End If

'獲取NongliData(m)的第n個(gè)二進(jìn)制位的值

bit = NongliData(m)

For i = 1 To n Step 1

bit = Int(bit / 2)

Next

bit = bit Mod 2

If (TheDate = 29 + bit) Then

isEnd = 1

Exit Do

End If

TheDate = TheDate - 29 - bit

n = n - 1

Loop

If (isEnd = 1) Then

Exit Do

End If

m = m + 1

Loop

curYear = 1921 + m

curMonth = k - n + 1

curDay = TheDate

If (k = 12) Then

If (curMonth = (Int(NongliData(m) / 65536) + 1))

Then

curMonth = 1 - curMonth

Else

If (curMonth (Int(NongliData(m) / 65536) + 1))

Then

curMonth = curMonth - 1

End If

End If

'生成農(nóng)歷天干、地支、屬相 ==

NongliStr

NongliStr = "農(nóng)歷" TianGan(((curYear - 4) Mod 60) Mod 10) DiZhi(((curYear - 4) Mod 60) Mod 12) "年"

NongliStr = NongliStr "(" ShuXiang(((curYear - 4) Mod 60) Mod 12) ")"

'生成農(nóng)歷月、日 == NongliDayStr

If (curMonth 1) Then

NongliDayStr = "閏" MonName(-1 * curMonth)

Else

NongliDayStr = MonName(curMonth)

End If

NongliDayStr = NongliDayStr "月"

NongliDayStr = NongliDayStr DayName(curDay)

NongLi = NongliStr NongliDayStr

End Function

將上面這段代碼保存在模塊中,就可以用公式

=nongli(A1)

調(diào)用了。

用vb編寫(xiě)萬(wàn)年歷小程序

用VB做萬(wàn)年歷,非常關(guān)鍵點(diǎn)就是農(nóng)歷寫(xiě)法,參考代碼如下:

#Region " 返回農(nóng)歷 "

'返回農(nóng)歷

'cCalendar.MaxSupportedDateTime 返回支持的最大日期,即2101-1-28

'cCalendar.MinSupportedDateTime 返回支持的最小日期,即190-2-19

Private cCalendar As New System.Globalization.ChineseLunisolarCalendar

Public Function PubFunGet_CNDate(ByVal sDateTime As Date) As String

cCalendar = New System.Globalization.ChineseLunisolarCalendar

Dim lyear As Integer = cCalendar.GetYear(sDateTime)

Dim lmonth As Integer = cCalendar.GetMonth(sDateTime)

Dim lday As Integer = cCalendar.GetDayOfMonth(sDateTime)

Dim lweek As Integer = cCalendar.GetDayOfWeek(sDateTime)

'獲取閏月, 0 則表示沒(méi)有閏月

Dim leapMonth As Integer = cCalendar.GetLeapMonth(lyear)

Dim isleap As Boolean = False

If (leapMonth 0) Then

If (leapMonth = lmonth) Then

'閏月

isleap = True

lmonth = lmonth - 1

ElseIf (lmonth leapMonth) Then

lmonth = lmonth - 1

End If

End If

Return String.Concat(GetLunisolarYear(lyear), IIf(isleap = True, "閏年", "年"), GetLunisolarMonth(lmonth), "月", GetLunisolarDay(lday))

End Function

'十天干

Private tiangan As String() = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}

'十二地支

Private dizhi As String() = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}

'十二生肖

Private shengxiao As String() = {"鼠", "牛", "虎", "免", "龍", "蛇", "馬", "羊", "猴", "雞", "狗", "豬"}

'農(nóng)歷月

Private months As String() = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二(臘)"}

'農(nóng)歷日

Private days1 As String() = {"初", "十", "廿", "三"}

Private days As String() = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}

'返回農(nóng)歷年(天干 地支 生肖)

Private Function GetLunisolarYear(ByVal year As Integer) As String

GetLunisolarYear = ""

If (year 3) Then

Dim tgIndex As Integer = (year - 4) Mod 10

Dim dzIndex As Integer = (year - 4) Mod 12

Return tiangan(tgIndex) dizhi(dzIndex) "[" shengxiao(dzIndex) "]"

End If

'無(wú)效的年份!

End Function

'返回生肖

Private Function GetShengXiao(ByVal sDateTime As Date) As String

Return shengxiao(cCalendar.GetTerrestrialBranch(cCalendar.GetSexagenaryYear(sDateTime)) - 1)

End Function

'返回農(nóng)歷月

Private Function GetLunisolarMonth(ByVal month As Integer) As String

GetLunisolarMonth = ""

If (month 13 AndAlso month 0) Then

Return months(month - 1)

End If

'無(wú)效的月份!

End Function

'返回農(nóng)歷日

Private Function GetLunisolarDay(ByVal day As Integer) As String

GetLunisolarDay = ""

If (day 0 AndAlso day 32) Then

If (day 20 AndAlso day 30) Then

Return String.Concat(days1((day - 1) \ 10), days((day - 1) Mod 10))

Else

Return String.Concat(days((day - 1) \ 10), days1(1))

End If

End If

'無(wú)效的日!

End Function

#End Region

VB 農(nóng)歷的計(jì)算方法

'下面是一個(gè)關(guān)于VB的農(nóng)歷算法

'提供基本計(jì)算方法,具體應(yīng)用自己補(bǔ)充

'日期數(shù)據(jù)定義方法如下

'前12個(gè)字節(jié)代表1-12月為大月或是小月,1為大月30天,0為小月29天,

'第13位為閏月的情況,1為大月30天,0為小月29天,第14位為閏月的月

'份,如果不是閏月為0,否則給出月份,10、11、12分別用A、B、C來(lái)表

'示,即使用16進(jìn)制。最后4位為當(dāng)年家農(nóng)歷新年-即農(nóng)歷1月1日所在公歷

'的日期,如0131代表1月31日。

'GetYLDate函數(shù)使用方式如下tYear為要輸入的年,tMonth為月,tDay為

'日期,YLyear是返回值,返加農(nóng)歷的年份,如甲子年,YLShuXing返回

'的是屬象,如鼠。IsGetGl是設(shè)置是不是通過(guò)農(nóng)歷取公歷值,如果是,

'前三個(gè)返回相應(yīng)的公歷日期,而且返回值是一個(gè)公歷日期。

Function GetYLDate(tYear As Integer, tMonth As Integer, tDay As Integer, _

YLyear As String, YLShuXing As String, _

Optional IsGetGl As Boolean) As String

On Error Resume Next

Dim daList(1900 To 2011) As String * 18

Dim conDate As Date, setDate As Date

Dim AddMonth As Integer, AddDay As Integer, AddYear As Integer, getDay As Integer

Dim RunYue As Boolean

If tYear 2010 Or tYear 1901 Then Exit Function '如果不是有效有日期,退出

'1900 to 1909

daList(1900) = "010010110110180131"

daList(1901) = "010010101110000219"

daList(1902) = "101001010111000208"

daList(1903) = "010100100110150129"

daList(1904) = "110100100110000216"

daList(1905) = "110110010101000204"

daList(1906) = "011010101010140125"

daList(1907) = "010101101010000213"

daList(1908) = "100110101101000202"

daList(1909) = "010010101110120122"

daList(1910) = "010010101110000210"

daList(1911) = "101001001101160130"

daList(1912) = "101001001101000218"

daList(1913) = "110100100101000206"

daList(1914) = "110101010100150126"

daList(1915) = "101101010101000214"

daList(1916) = "010101101010000204"

daList(1917) = "100101101101020123"

daList(1918) = "100101011011000211"

daList(1919) = "010010011011170201"

daList(1920) = "010010011011000220"

daList(1921) = "101001001011000208"

daList(1922) = "101100100101150128"

daList(1923) = "011010100101000216"

daList(1924) = "011011010100000205"

daList(1925) = "101011011010140124"

daList(1926) = "001010110110000213"

daList(1927) = "100101010111000202"

daList(1928) = "010010010111120123"

daList(1929) = "010010010111000210"

daList(1930) = "011001001011060130"

daList(1931) = "110101001010000217"

daList(1932) = "111010100101000206"

daList(1933) = "011011010100150126"

daList(1934) = "010110101101000214"

daList(1935) = "001010110110000204"

daList(1936) = "100100110111030124"

daList(1937) = "100100101110000211"

daList(1938) = "110010010110170131"

daList(1939) = "110010010101000219"

daList(1940) = "110101001010000208"

daList(1941) = "110110100101060127"

daList(1942) = "101101010101000215"

daList(1943) = "010101101010000205"

daList(1944) = "101010101101140125"

daList(1945) = "001001011101000213"

daList(1946) = "100100101101000202"

daList(1947) = "110010010101120122"

daList(1948) = "101010010101000210"

daList(1949) = "101101001010170129"

daList(1950) = "011011001010000217"

daList(1951) = "101101010101000206"

daList(1952) = "010101011010150127"

daList(1953) = "010011011010000214"

daList(1954) = "101001011011000203"

daList(1955) = "010100101011130124"

daList(1956) = "010100101011000212"

daList(1957) = "101010010101080131"

daList(1958) = "111010010101000218"

daList(1959) = "011010101010000208"

daList(1960) = "101011010101060128"

daList(1961) = "101010110101000215"

daList(1962) = "010010110110000205"

daList(1963) = "101001010111040125"

daList(1964) = "101001010111000213"

daList(1965) = "010100100110000202"

daList(1966) = "111010010011030121"

daList(1967) = "110110010101000209"

daList(1968) = "010110101010170130"

daList(1969) = "010101101010000217"

daList(1970) = "100101101101000206"

daList(1971) = "010010101110150127"

daList(1972) = "010010101101000215"

daList(1973) = "101001001101000203"

daList(1974) = "110100100110140123"

daList(1975) = "110100100101000211"

daList(1976) = "110101010010180131"

daList(1977) = "101101010100000218"

daList(1978) = "101101101010000207"

daList(1979) = "100101101101060128"

daList(1980) = "100101011011000216"

daList(1981) = "010010011011000205"

daList(1982) = "101001001011140125"

daList(1983) = "101001001011000213"

daList(1984) = "1011001001011A0202"

daList(1985) = "011010100101000220"

daList(1986) = "011011010100000209"

daList(1987) = "101011011010060129"

daList(1988) = "101010110110000217"

daList(1989) = "100100110111000206"

daList(1990) = "010010010111150127"

daList(1991) = "010010010111000215"

daList(1992) = "011001001011000204"

daList(1993) = "011010100101030123"

daList(1994) = "111010100101000210"

daList(1995) = "011010110010180131"

daList(1996) = "010110101100000219"

daList(1997) = "101010110110000207"

daList(1998) = "100100110110150128"

daList(1999) = "100100101110000216"

daList(2000) = "110010010110000205"

daList(2001) = "110101001010140124"

daList(2002) = "110101001010000212"

daList(2003) = "110110100101000201"

daList(2004) = "010110101010120122"

daList(2005) = "010101101010000209"

daList(2006) = "101010101101170129"

daList(2007) = "001001011101000218"

daList(2008) = "100100101101000207"

daList(2009) = "110010010101150126"

daList(2010) = "101010010101000214"

daList(2011) = "101101001010000214"

AddYear = tYear

RunYue = False

If IsGetGl Then

AddMonth = Val(Mid(daList(AddYear), 15, 2))

AddDay = Val(Mid(daList(AddYear), 17, 2))

conDate = DateSerial(AddYear, AddMonth, AddDay)

AddDay = tDay

For i = 1 To tMonth - 1

AddDay = AddDay + 29 + Val(Mid(daList(tYear), i, 1))

Next i

'MsgBox DateDiff("d", conDate, Date)

setDate = DateAdd("d", AddDay - 1, conDate)

GetYLDate = setDate

tYear = Year(setDate)

tMonth = Month(setDate)

tDay = Day(setDate)

Exit Function

End If

CHUSHIHUA:

AddMonth = Val(Mid(daList(AddYear), 15, 2))

AddDay = Val(Mid(daList(AddYear), 17, 2))

conDate = DateSerial(AddYear, AddMonth, AddDay)

setDate = DateSerial(tYear, tMonth, tDay)

getDay = DateDiff("d", conDate, setDate)

If getDay 0 Then AddYear = AddYear - 1: GoTo CHUSHIHUA

' addday = NearDay

AddDay = 1: AddMonth = 1

For i = 1 To getDay

AddDay = AddDay + 1

If AddDay = 30 + Mid(daList(AddYear), AddMonth, 1) Or (RunYue And AddDay = 30 + Mid(daList(AddYear), 13, 1)) Then

If RunYue = False And AddMonth = Val("H" Mid(daList(AddYear), 14, 1)) Then

RunYue = True

Else

RunYue = False

AddMonth = AddMonth + 1

End If

AddDay = 1

End If

Next

md$ = "初一初二初三初四初五初六初七初八初九初十十一十二十三十四十五十六十七十八十九二十廿一廿二廿三廿四廿五廿六廿七廿八廿九三十"

dd$ = Mid(md$, (AddDay - 1) * 2 + 1, 2)

mm$ = Mid("正二三四五六七八九十寒臘", AddMonth, 1) + "月"

YouGetDate = DateSerial(AddYear, AddMonth, AddDay)

tiangan$ = "甲乙丙丁戊已庚辛壬癸"

dizhi$ = "子丑寅卯辰巳午未申酉戌亥"

Dim ganzhi(0 To 59) As String * 2

For i = 0 To 59

ganzhi(i) = Mid(tiangan$, (i Mod 10) + 1, 1) + Mid(dizhi$, (i Mod 12) + 1, 1)

'ff$ = ff$ + ganzhi(i)

Next i

'MsgBox ff$, , Len(ff$)

YLyear = ganzhi((AddYear - 4) Mod 60)

shu$ = "鼠牛虎兔龍蛇馬羊猴雞狗豬"

YLShuXing = Mid(shu$, ((AddYear - 4) Mod 12) + 1, 1)

If RunYue Then mm$ = "閏" + mm$

GetYLDate = mm$ + dd$

End Function

'下面是一個(gè)使用的例子,你需要在窗體上加上一個(gè)按扭,并命名為Command1,然后將下列代碼復(fù)制到窗體的代碼中

Private Sub Command1_Click()

Dim ty As Integer, tm As Integer, td As Integer, yl As String, sx As String

'取公歷1999年10月28日的農(nóng)歷日期

ty = 1999

tm = 10

td = 28

t = GetYLDate(ty, tm, td, yl, sx)

MsgBox t

MsgBox ty "-" tm "-" td " " yl " " sx

'取1999年農(nóng)歷十月28的公歷日期

t = GetYLDate(ty, tm, td, yl, sx, True)

MsgBox t

MsgBox ty "-" tm "-" td " " yl " " sx

End Sub

VB.NET的陽(yáng)歷與農(nóng)歷轉(zhuǎn)換的算法

根據(jù)經(jīng)驗(yàn), 這個(gè)算法非常復(fù)雜. 經(jīng)過(guò)查找,終于得到一些資料, 在此愿與大家分享。 首先陰歷以月為基本單位,一個(gè)月以新月出現(xiàn)的那一天為始直至下一個(gè)新月出現(xiàn)的前一天。 由于月亮公轉(zhuǎn)的周期介于29到30天之間,陰歷的一個(gè)月也就由新月出現(xiàn)時(shí)刻的早晚或是29天或是30天。 大月為30天,小月為29天。 與陽(yáng)歷不同的是,大小月在不同的年中不固定。 如春節(jié)的前一天常稱為大年三十,但有不少年如2000年的陰歷十二月只有29天。 由于十二個(gè)月的時(shí)間較陽(yáng)歷年即地球繞太陽(yáng)公轉(zhuǎn)一周的時(shí)間短11天左右. 為了使陰歷年與陽(yáng)歷年保持相對(duì)穩(wěn)定,每隔兩三年就需要加入一個(gè)閏月。 大約每十九年要加入七個(gè)閏月。 而二十四節(jié)氣則是由地球在繞太陽(yáng)公轉(zhuǎn)的軌道上的位置確定的。 以每年的冬至為始,每15度為一個(gè)節(jié)氣。 是故二十四節(jié)氣在陽(yáng)歷的每月中有大概固定的日期。 古時(shí)以二十四節(jié)氣指導(dǎo)農(nóng)耕,這就是陰歷又稱農(nóng)歷的原因。 其中陽(yáng)歷下半月的十二個(gè)節(jié)氣又稱為中氣。 中氣出現(xiàn)的時(shí)刻和閏月的確定有直接的關(guān)系。 陰歷的計(jì)算有下列四條規(guī)則: 1.所有新月和節(jié)氣出現(xiàn)的時(shí)刻的計(jì)算以東經(jīng)120度即東八區(qū)標(biāo)準(zhǔn)時(shí)為準(zhǔn)。 但計(jì)算1929年以前的陰歷時(shí)應(yīng)以北京即東經(jīng)116度25分的當(dāng)?shù)貢r(shí)為準(zhǔn)。 2.新月出現(xiàn)的一天為一個(gè)月的第一天。 如某個(gè)節(jié)氣的出現(xiàn)時(shí)刻也在這一天,則不論該節(jié)氣的出現(xiàn)時(shí)刻是否比新月晚,一律算落入新的一個(gè)月中。 3.每年的冬至總是落在這年的十一月中。 從一年的冬至的第二天起到下一年冬至這一天止的這段時(shí)間稱為一歲。 如一歲中有十三個(gè)新月出現(xiàn),則這一歲為閏歲,要加入一個(gè)閏月。 4.閏歲中第一個(gè)沒(méi)有中氣的月為閏月。 因?yàn)橐粴q中只有十二個(gè)中氣,所以閏歲中至少有一個(gè)月沒(méi)有中氣,也存在有兩個(gè)月沒(méi)有中氣的可能性。 但這種情況下只有第一個(gè)沒(méi)有中氣的月為閏月。 閏月的前一個(gè)月為幾月則該閏月稱為閏幾月。 根據(jù)以上信息, 我們知道農(nóng)歷是根據(jù)天文觀測(cè)進(jìn)行指定的(也許可以在天文學(xué)的書(shū)上找到說(shuō)明)。 為了簡(jiǎn)化轉(zhuǎn)換計(jì)算, 很多程序人員設(shè)計(jì)了基于"時(shí)間段內(nèi)查表"方法的例程. 更具體的說(shuō)明和源碼請(qǐng)參考下面這些資料:

實(shí)現(xiàn)陽(yáng)歷轉(zhuǎn)陰歷算法

下面是一個(gè)關(guān)于VB的農(nóng)歷算法

'日期數(shù)據(jù)定義方法如下

'前12個(gè)字節(jié)代表1-12月為大月或是小月,1為大月30天,0為小月29天;

'第13位為閏月的情況,1為大月30天,0為小月29天;

'第14位為閏月的月份,如果不是閏月為0,否則給出月份,10、11、12分別用A、B、C來(lái)表示,即使用16進(jìn)制;

'最后4位為當(dāng)年家農(nóng)歷新年-即農(nóng)歷1月1日所在公歷的日期,如0131代表1月31日。

Function GetChgDate(ByVal vDate As String, ByVal ChgType As 轉(zhuǎn)換方式) As String

Dim vvdate() As String = Split(vDate, "-")

If vvdate(0) 2011 Or vvdate(0) 1900 Then

Throw New NotSupportedException("本函數(shù)只提供1900年至2011年的日歷轉(zhuǎn)換!")

End If

Dim AddMonth, AddDay, AddYear, getDay, i As Integer

Dim RunYue As Boolean

Dim conDate As DateTime

Dim daList(2011) As String

daList(1900) = "010010110110180131"

daList(1901) = "010010101110000219"

daList(1902) = "101001010111000208"

daList(1903) = "010100100110150129"

daList(1904) = "110100100110000216"

daList(1905) = "110110010101000204"

daList(1906) = "011010101010140125"

daList(1907) = "010101101010000213"

daList(1908) = "100110101101000202"

daList(1909) = "010010101110120122"

daList(1910) = "010010101110000210"

daList(1911) = "101001001101160130"

daList(1912) = "101001001101000218"

daList(1913) = "110100100101000206"

daList(1914) = "110101010100150126"

daList(1915) = "101101010101000214"

daList(1916) = "010101101010000204"

daList(1917) = "100101101101020123"

daList(1918) = "100101011011000211"

daList(1919) = "010010011011170201"

daList(1920) = "010010011011000220"

daList(1921) = "101001001011000208"

daList(1922) = "101100100101150128"

daList(1923) = "011010100101000216"

daList(1924) = "011011010100000205"

daList(1925) = "101011011010140124"

daList(1926) = "001010110110000213"

daList(1927) = "100101010111000202"

daList(1928) = "010010010111120123"

daList(1929) = "010010010111000210"

daList(1930) = "011001001011060130"

daList(1931) = "110101001010000217"

daList(1932) = "111010100101000206"

daList(1933) = "011011010100150126"

daList(1934) = "010110101101000214"

daList(1935) = "001010110110000204"

daList(1936) = "100100110111030124"

daList(1937) = "100100101110000211"

daList(1938) = "110010010110170131"

daList(1939) = "110010010101000219"

daList(1940) = "110101001010000208"

daList(1941) = "110110100101060127"

daList(1942) = "101101010101000215"

daList(1943) = "010101101010000205"

daList(1944) = "101010101101140125"

daList(1945) = "001001011101000213"

daList(1946) = "100100101101000202"

daList(1947) = "110010010101120122"

daList(1948) = "101010010101000210"

daList(1949) = "101101001010170129"

daList(1950) = "011011001010000217"

daList(1951) = "101101010101000206"

daList(1952) = "010101011010150127"

daList(1953) = "010011011010000214"

daList(1954) = "101001011011000203"

daList(1955) = "010100101011130124"

daList(1956) = "010100101011000212"

daList(1957) = "101010010101080131"

daList(1958) = "111010010101000218"

daList(1959) = "011010101010000208"

daList(1960) = "101011010101060128"

daList(1961) = "101010110101000215"

daList(1962) = "010010110110000205"

daList(1963) = "101001010111040125"

daList(1964) = "101001010111000213"

daList(1965) = "010100100110000202"

daList(1966) = "111010010011030121"

daList(1967) = "110110010101000209"

daList(1968) = "010110101010170130"

daList(1969) = "010101101010000217"

daList(1970) = "100101101101000206"

daList(1971) = "010010101110150127"

daList(1972) = "010010101101000215"

daList(1973) = "101001001101000203"

daList(1974) = "110100100110140123"

daList(1975) = "110100100101000211"

daList(1976) = "110101010010180131"

daList(1977) = "101101010100000218"

daList(1978) = "101101101010000207"

daList(1979) = "100101101101060128"

daList(1980) = "100101011011000216"

daList(1981) = "010010011011000205"

daList(1982) = "101001001011140125"

daList(1983) = "101001001011000213"

daList(1984) = "1011001001011A0202"

daList(1985) = "011010100101000220"

daList(1986) = "011011010100000209"

daList(1987) = "101011011010060129"

daList(1988) = "101010110110000217"

daList(1989) = "100100110111000206"

daList(1990) = "010010010111150127"

daList(1991) = "010010010111000215"

daList(1992) = "011001001011000204"

daList(1993) = "011010100101030123"

daList(1994) = "111010100101000210"

daList(1995) = "011010110010180131"

daList(1996) = "010110101100000219"

daList(1997) = "101010110110000207"

daList(1998) = "100100110110150128"

daList(1999) = "100100101110000216"

daList(2000) = "110010010110000205"

daList(2001) = "110101001010140124"

daList(2002) = "110101001010000212"

daList(2003) = "110110100101000201"

daList(2004) = "010110101010120122"

daList(2005) = "010101101010000209"

daList(2006) = "101010101101170129"

daList(2007) = "001001011101000218"

daList(2008) = "100100101101000207"

daList(2009) = "110010010101150126"

daList(2010) = "101010010101000214"

daList(2011) = "101101001010000214"

AddYear = vvdate(0)

If ChgType = 轉(zhuǎn)換方式.陰歷轉(zhuǎn)陽(yáng)歷 Then

AddMonth = Val(Mid(daList(AddYear), 15, 2))

AddDay = Val(Mid(daList(AddYear), 17, 2))

conDate = DateSerial(AddYear, AddMonth, AddDay)

AddDay = vvdate(2)

For i = 1 To vvdate(1) - 1

AddDay = AddDay + 29 + Val(Mid(daList(vvdate(0)), i, 1))

Next i

Return DateAdd(DateInterval.Day, AddDay - 1, conDate)

Else

CHUSHIHUA:

AddMonth = Val(Mid(daList(AddYear), 15, 2))

AddDay = Val(Mid(daList(AddYear), 17, 2))

conDate = DateSerial(AddYear, AddMonth, AddDay)

Dim vtDate As DateTime

Try

vtDate = CType(vDate, DateTime)

Catch ex As Exception

Throw New NotSupportedException("陽(yáng)歷日期輸入錯(cuò)誤!")

End Try

getDay = DateDiff(DateInterval.Day, conDate, vtDate)

If getDay 0 Then AddYear = AddYear - 1 : GoTo CHUSHIHUA

AddDay = 1

AddMonth = 1

For i = 1 To getDay

AddDay = AddDay + 1

If AddDay = 30 + Mid(daList(AddYear), AddMonth, 1) Or (RunYue And AddDay = 30 + Mid(daList(AddYear), 13, 1)) Then

If RunYue = False And AddMonth = Val("H" Mid(daList(AddYear), 14, 1)) Then

RunYue = True

Else

RunYue = False

AddMonth = AddMonth + 1

End If

AddDay = 1

End If

Next

Return AddYear "-" AddMonth "-" AddDay

End If

End Function

Enum 轉(zhuǎn)換方式

陰歷轉(zhuǎn)陽(yáng)歷 = 1

陽(yáng)歷轉(zhuǎn)陰歷 = 0

End Enum


網(wǎng)頁(yè)標(biāo)題:vb.net農(nóng)歷轉(zhuǎn)日歷 vb 農(nóng)歷
轉(zhuǎn)載源于:http://weahome.cn/article/dodsjig.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部