- 爱易网页
-
ASP.NET教程
- VB.NET的阳历与农历转换的算法
日期:2012-11-08 浏览次数:20530 次
'下面是一个关于VB的农历算法
'日期数据定义方法如下
'前12个字节代表1-12月为大月或是小月,1为大月30天,0为小月29天;
'第13位为闰月的情况,1为大月30天,0为小月29天;
'第14位为闰月的月份,如果不是闰月为0,否则给出月份,10、11、12分别用A、B、C来表示,即使用16进制;
'最后4位为当年家农历新年-即农历1月1日所在公历的日期,如0131代表1月31日。
Function GetChgDate(ByVal vDate As String, ByVal ChgType As 转换方式) As String
Dim vvdate() As String = Split(vDate, "-")
If vvdate(0) > 2011 Or vvdate(0) < 1900 Then
Throw New NotSupportedException("本函数只提供1900年至2011年的日历转换!")
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"