公历农历转换器 - 副本、爬至https://www.buyiju.com/cha/yyl.asp网站
源码改进之后如下
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Cache-Control" content="no-transform" /> 6 <meta http-equiv="Cache-Control" content="no-siteapp" /> 7 8 </head> 9 <body> 10 <div class="wrapper"> 11 <div class="plt"> 12 <div class="viewbox"> 13 <div class="title"> 14 <h2>阴历阳历互转 公历农历转换器</h2></div> 15 <div class="info"><small>一般意义上讲,阴历即是农历,阳历即是公历。</small></div> 16 <FORM name="form_jisuan"> 17 <div class="inform center"> 18 <font color="#ff0000">农历</font>:<select name="nyear" class="zbslt"> 19 <option value="1950" >1950</option> 20 <option value="1951" >1951</option> 21 <option value="1952" >1952</option> 22 <option value="1953" >1953</option> 23 <option value="1954" >1954</option> 24 <option value="1955" >1955</option> 25 <option value="1956" >1956</option> 26 <option value="1957" >1957</option> 27 <option value="1958" >1958</option> 28 <option value="1959" >1959</option> 29 <option value="1960" >1960</option> 30 <option value="1961" >1961</option> 31 <option value="1962" >1962</option> 32 <option value="1963" >1963</option> 33 <option value="1964" >1964</option> 34 <option value="1965" >1965</option> 35 <option value="1966" >1966</option> 36 <option value="1967" >1967</option> 37 <option value="1968" >1968</option> 38 <option value="1969" >1969</option> 39 <option value="1970" >1970</option> 40 <option value="1971" >1971</option> 41 <option value="1972" >1972</option> 42 <option value="1973" >1973</option> 43 <option value="1974" >1974</option> 44 <option value="1975" >1975</option> 45 <option value="1976" >1976</option> 46 <option value="1977" >1977</option> 47 <option value="1978" >1978</option> 48 <option value="1979" >1979</option> 49 <option value="1980" >1980</option> 50 <option value="1981" >1981</option> 51 <option value="1982" >1982</option> 52 <option value="1983" >1983</option> 53 <option value="1984" >1984</option> 54 <option value="1985" >1985</option> 55 <option value="1986" >1986</option> 56 <option value="1987" >1987</option> 57 <option value="1988" >1988</option> 58 <option value="1989" >1989</option> 59 <option value="1990" >1990</option> 60 <option value="1991" >1991</option> 61 <option value="1992" >1992</option> 62 <option value="1993" >1993</option> 63 <option value="1994" >1994</option> 64 <option value="1995" >1995</option> 65 <option value="1996" >1996</option> 66 <option value="1997" >1997</option> 67 <option value="1998" selected>1998</option> 68 <option value="1999" >1999</option> 69 <option value="2000" >2000</option> 70 <option value="2001" >2001</option> 71 <option value="2002" >2002</option> 72 <option value="2003" >2003</option> 73 <option value="2004" >2004</option> 74 <option value="2005" >2005</option> 75 <option value="2006" >2006</option> 76 <option value="2007" >2007</option> 77 <option value="2008" >2008</option> 78 <option value="2009" >2009</option> 79 <option value="2010" >2010</option> 80 <option value="2011" >2011</option> 81 <option value="2012" >2012</option> 82 <option value="2013" >2013</option> 83 <option value="2014" >2014</option> 84 <option value="2015" >2015</option> 85 <option value="2016" >2016</option> 86 <option value="2017" >2017</option> 87 <option value="2018" >2018</option> 88 <option value="2019" >2019</option> 89 <option value="2020" >2020</option> 90 <option value="2021" >2021</option> 91 </select> 年 <select name="nmonth" class="zbslt"> 92 <option value="1" >1</option> 93 <option value="2" >2</option> 94 <option value="3" selected>3</option> 95 <option value="4" >4</option> 96 <option value="5" >5</option> 97 <option value="6" >6</option> 98 <option value="7" >7</option> 99 <option value="8" >8</option> 100 <option value="9" >9</option> 101 <option value="10" >10</option> 102 <option value="11" >11</option> 103 <option value="12" >12</option> 104 </select> 月 105 <select name="nday" class="zbslt"> 106 <option value="1" >1</option> 107 <option value="2" >2</option> 108 <option value="3" >3</option> 109 <option value="4" >4</option> 110 <option value="5" >5</option> 111 <option value="6" >6</option> 112 <option value="7" >7</option> 113 <option value="8" >8</option> 114 <option value="9" >9</option> 115 <option value="10" >10</option> 116 <option value="11" >11</option> 117 <option value="12" >12</option> 118 <option value="13" >13</option> 119 <option value="14" >14</option> 120 <option value="15" >15</option> 121 <option value="16" >16</option> 122 <option value="17" >17</option> 123 <option value="18" >18</option> 124 <option value="19" >19</option> 125 <option value="20" >20</option> 126 <option value="21" >21</option> 127 <option value="22" >22</option> 128 <option value="23" >23</option> 129 <option value="24" >24</option> 130 <option value="25" >25</option> 131 <option value="26" >26</option> 132 <option value="27" selected>27</option> 133 <option value="28" >28</option> 134 <option value="29" >29</option> 135 <option value="30" >30</option> 136 </select> 日 137 <input type="hidden" name="nongli" value="农历" /> 138 <input type="button" value="转为阳历" onClick="CalConv(1);" class="zbbtn2"> 139 <div id="ddd1" class="red" align="center"></div> 140 </div> 141 <div class="inform center"> 142 <font color="#ff0000">公历</font>:<select name="yyear" class="zbslt"> 143 <option value="1950" >1950</option> 144 <option value="1951" >1951</option> 145 <option value="1952" >1952</option> 146 <option value="1953" >1953</option> 147 <option value="1954" >1954</option> 148 <option value="1955" >1955</option> 149 <option value="1956" >1956</option> 150 <option value="1957" >1957</option> 151 <option value="1958" >1958</option> 152 <option value="1959" >1959</option> 153 <option value="1960" >1960</option> 154 <option value="1961" >1961</option> 155 <option value="1962" >1962</option> 156 <option value="1963" >1963</option> 157 <option value="1964" >1964</option> 158 <option value="1965" >1965</option> 159 <option value="1966" >1966</option> 160 <option value="1967" >1967</option> 161 <option value="1968" >1968</option> 162 <option value="1969" >1969</option> 163 <option value="1970" >1970</option> 164 <option value="1971" >1971</option> 165 <option value="1972" >1972</option> 166 <option value="1973" >1973</option> 167 <option value="1974" >1974</option> 168 <option value="1975" >1975</option> 169 <option value="1976" >1976</option> 170 <option value="1977" >1977</option> 171 <option value="1978" >1978</option> 172 <option value="1979" >1979</option> 173 <option value="1980" >1980</option> 174 <option value="1981" >1981</option> 175 <option value="1982" >1982</option> 176 <option value="1983" >1983</option> 177 <option value="1984" >1984</option> 178 <option value="1985" >1985</option> 179 <option value="1986" >1986</option> 180 <option value="1987" >1987</option> 181 <option value="1988" >1988</option> 182 <option value="1989" >1989</option> 183 <option value="1990" >1990</option> 184 <option value="1991" >1991</option> 185 <option value="1992" >1992</option> 186 <option value="1993" >1993</option> 187 <option value="1994" >1994</option> 188 <option value="1995" >1995</option> 189 <option value="1996" >1996</option> 190 <option value="1997" >1997</option> 191 <option value="1998" selected>1998</option> 192 <option value="1999" >1999</option> 193 <option value="2000" >2000</option> 194 <option value="2001" >2001</option> 195 <option value="2002" >2002</option> 196 <option value="2003" >2003</option> 197 <option value="2004" >2004</option> 198 <option value="2005" >2005</option> 199 <option value="2006" >2006</option> 200 <option value="2007" >2007</option> 201 <option value="2008" >2008</option> 202 <option value="2009" >2009</option> 203 <option value="2010" >2010</option> 204 <option value="2011" >2011</option> 205 <option value="2012" >2012</option> 206 <option value="2013" >2013</option> 207 <option value="2014" >2014</option> 208 <option value="2015" >2015</option> 209 <option value="2016" >2016</option> 210 <option value="2017" >2017</option> 211 <option value="2018" >2018</option> 212 <option value="2019" >2019</option> 213 <option value="2020" >2020</option> 214 <option value="2021" >2021</option> 215 </select> 年 <select name="ymonth" class="zbslt"> 216 <option value="1" >1</option> 217 <option value="2" >2</option> 218 <option value="3" selected>3</option> 219 <option value="4" >4</option> 220 <option value="5" >5</option> 221 <option value="6" >6</option> 222 <option value="7" >7</option> 223 <option value="8" >8</option> 224 <option value="9" >9</option> 225 <option value="10" >10</option> 226 <option value="11" >11</option> 227 <option value="12" >12</option> 228 </select> 月 229 <select name="yday" class="zbslt"> 230 <option value="1" >1</option> 231 <option value="2" >2</option> 232 <option value="3" >3</option> 233 <option value="4" >4</option> 234 <option value="5" >5</option> 235 <option value="6" >6</option> 236 <option value="7" >7</option> 237 <option value="8" >8</option> 238 <option value="9" >9</option> 239 <option value="10" >10</option> 240 <option value="11" >11</option> 241 <option value="12" >12</option> 242 <option value="13" >13</option> 243 <option value="14" >14</option> 244 <option value="15" >15</option> 245 <option value="16" >16</option> 246 <option value="17" >17</option> 247 <option value="18" >18</option> 248 <option value="19" >19</option> 249 <option value="20" >20</option> 250 <option value="21" >21</option> 251 <option value="22" >22</option> 252 <option value="23" >23</option> 253 <option value="24" >24</option> 254 <option value="25" >25</option> 255 <option value="26" >26</option> 256 <option value="27" selected>27</option> 257 <option value="28" >28</option> 258 <option value="29" >29</option> 259 <option value="30" >30</option> 260 <option value="31" >31</option> 261 </select> 日 <input type="hidden" name="gongli" value="公历" /> 262 <input type="button" value="转为阴历" onClick="CalConv(0);" class="zbbtn2"> 263 <div id="ddd2" class="red" align="center"></div> 264 </div> 265 </form> 266 </div><!-- /viewbox --> 267 </div><!-- //plt --> 268 </div> 269 <!-- /wrapper --> 270 <SCRIPT language=JavaScript> 271 function CalConv(M) 272 { 273 FIRSTYEAR = 1936; 274 LASTYEAR = 2031; 275 276 LunarCal = [ 277 new tagLunarCal(23, 3, 2, 17, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ), /* 1936 */ 278 new tagLunarCal( 41, 0, 4, 23, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), 279 new tagLunarCal( 30, 7, 5, 28, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), 280 new tagLunarCal( 49, 0, 6, 33, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), 281 new tagLunarCal( 38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 1940 */ 282 new tagLunarCal( 26, 6, 2, 44, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), 283 new tagLunarCal( 45, 0, 3, 49, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), 284 new tagLunarCal( 35, 0, 4, 54, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), 285 new tagLunarCal( 24, 4, 5, 59, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1944 */ 286 new tagLunarCal( 43, 0, 0, 5, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ), 287 new tagLunarCal( 32, 0, 1, 10, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), 288 new tagLunarCal( 21, 2, 2, 15, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), 289 new tagLunarCal( 40, 0, 3, 20, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), /* 1948 */ 290 new tagLunarCal( 28, 7, 5, 26, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), 291 new tagLunarCal( 47, 0, 6, 31, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1 ), 292 new tagLunarCal( 36, 0, 0, 36, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), 293 new tagLunarCal( 26, 5, 1, 41, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), /* 1952 */ 294 new tagLunarCal( 44, 0, 3, 47, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1 ), 295 new tagLunarCal( 33, 0, 4, 52, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), 296 new tagLunarCal( 23, 3, 5, 57, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), 297 new tagLunarCal( 42, 0, 6, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), /* 1956 */ 298 new tagLunarCal( 30, 8, 1, 8, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), 299 new tagLunarCal( 48, 0, 2, 13, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), 300 new tagLunarCal( 38, 0, 3, 18, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), 301 new tagLunarCal( 27, 6, 4, 23, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 1960 */ 302 new tagLunarCal( 45, 0, 6, 29, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ), 303 new tagLunarCal( 35, 0, 0, 34, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), 304 new tagLunarCal( 24, 4, 1, 39, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), 305 new tagLunarCal( 43, 0, 2, 44, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), /* 1964 */ 306 new tagLunarCal( 32, 0, 4, 50, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), 307 new tagLunarCal( 20, 3, 5, 55, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), 308 new tagLunarCal( 39, 0, 6, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), 309 new tagLunarCal( 29, 7, 0, 5, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 1968 */ 310 new tagLunarCal( 47, 0, 2, 11, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), 311 new tagLunarCal( 36, 0, 3, 16, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ), 312 new tagLunarCal( 26, 5, 4, 21, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1 ), 313 new tagLunarCal( 45, 0, 5, 26, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1972 */ 314 new tagLunarCal( 33, 0, 0, 32, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1 ), 315 new tagLunarCal( 22, 4, 1, 37, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), 316 new tagLunarCal( 41, 0, 2, 42, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ), 317 new tagLunarCal( 30, 8, 3, 47, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ), /* 1976 */ 318 new tagLunarCal( 48, 0, 5, 53, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1 ), 319 new tagLunarCal( 37, 0, 6, 58, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), 320 new tagLunarCal( 27, 6, 0, 3, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ), 321 new tagLunarCal( 46, 0, 1, 8, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 1980 */ 322 new tagLunarCal( 35, 0, 3, 14, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 ), 323 new tagLunarCal( 24, 4, 4, 19, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ), 324 new tagLunarCal( 43, 0, 5, 24, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ), 325 new tagLunarCal( 32, 10, 6, 29, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ), /* 1984 */ 326 new tagLunarCal( 50, 0, 1, 35, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), 327 new tagLunarCal( 39, 0, 2, 40, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1 ), 328 new tagLunarCal( 28, 6, 3, 45, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 ), 329 new tagLunarCal( 47, 0, 4, 50, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 1988 */ 330 new tagLunarCal( 36, 0, 6, 56, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ), 331 new tagLunarCal( 26, 5, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1 ), 332 new tagLunarCal( 45, 0, 1, 6, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 ), 333 new tagLunarCal( 34, 0, 2, 11, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 ), /* 1992 */ 334 new tagLunarCal( 22, 3, 4, 17, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), 335 new tagLunarCal( 40, 0, 5, 22, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), 336 new tagLunarCal( 30, 8, 6, 27, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1 ), 337 new tagLunarCal( 49, 0, 0, 32, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 ), /* 1996 */ 338 new tagLunarCal( 37, 0, 2, 38, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), 339 new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ), 340 new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 1999 */ 341 new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 2000 */ 342 new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), 343 new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), 344 new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), 345 new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 2004 */ 346 new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), 347 new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), 348 new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ), 349 new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 2008 */ 350 new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), 351 new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), 352 new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), 353 new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 2012 */ 354 355 new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), 356 new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), 357 new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ), 358 new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 2016 */ 359 new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), 360 new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ), 361 new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), 362 new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 2020 */ 363 new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), 364 new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ), 365 new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), 366 new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 2024 */ 367 new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), 368 new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ), 369 new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), 370 new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 2028 */ 371 new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ), 372 new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ), 373 new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ]; 374 375 376 /* 西曆年每月之日數 */ 377 SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; 378 379 /* 西曆年每月之累積日數, 平年與閏年 */ 380 SolarDays = [ 381 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 382 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ]; 383 384 AnimalIdx = ["馬 ", "羊 ", "猴 ", "雞 ", "狗 ", "豬 ", "鼠 ", "牛 ", "虎 ", "兔 ", "龍 ", "蛇 " ]; 385 LocationIdx = [ "南", "東", "北", "西" ]; 386 387 388 if (M==0) { //阳历到阴历 389 if (!IsInteger(form_jisuan.yyear.value) || !IsInteger(form_jisuan.ymonth.value) || !IsInteger(form_jisuan.yday.value)) return alert("请输入合法阳历年月日数值"); 390 SolarYear = parseInt(form_jisuan.yyear.value); 391 SolarMonth = parseInt(form_jisuan.ymonth.value); 392 SolarDate = parseInt(form_jisuan.yday.value); 393 394 395 if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return alert("请输入1936-2031有效年份"); 396 397 sm = SolarMonth - 1; 398 399 if ( sm < 0 || sm > 11 ) return alert(请输入有效月份); 400 401 leap = GetLeap( SolarYear ); 402 403 if ( sm == 1 ) 404 d = leap + 28; 405 else 406 d = SolarCal[sm]; 407 408 if ( SolarDate < 1 || SolarDate > d ) return 3; 409 410 y = SolarYear - FIRSTYEAR; 411 acc = SolarDays[ leap*14 + sm ] + SolarDate; 412 kc = acc + LunarCal[y].BaseKanChih; 413 Kan = kc % 10; 414 Chih = kc % 12; 415 Location = LocationIdx[kc % 4]; 416 Age = kc % 60; 417 if ( Age < 22 ) 418 Age = 22 - Age; 419 else 420 Age = 82 - Age; 421 422 Age =Age + 3; 423 424 if (Age < 10) 425 Age=Age+60; 426 427 Animal = AnimalIdx[ Chih ]; 428 429 if ( acc <= LunarCal[y].BaseDays ) { 430 y--; 431 LunarYear = SolarYear - 1; 432 leap = GetLeap( LunarYear ); 433 sm += 12; 434 acc = SolarDays[leap*14 + sm] + SolarDate; 435 } 436 else 437 LunarYear = SolarYear; 438 439 l1 = LunarCal[y].BaseDays; 440 for ( i=0; i<13; i++ ) { 441 l2 = l1 + LunarCal[y].MonthDays[i] + 29; 442 if ( acc <= l2 ) break; 443 l1 = l2; 444 } 445 446 LunarMonth = i + 1; 447 LunarDate = acc - l1; 448 im = LunarCal[y].Intercalation; 449 450 if ( im != 0 && LunarMonth > im ) { 451 LunarMonth--; 452 if ( LunarMonth == im ) LunarMonth = -im; 453 } 454 455 if ( LunarMonth > 12 ) LunarMonth -= 12; 456 document.getElementById("ddd2").innerHTML="农历为:"+ LunarYear + "年" + LunarMonth + "月" + LunarDate + "日"; 457 //alert("农历为:"+ LunarYear + "年" + LunarMonth + "月" + LunarDate + "日" ); 458 return 0; 459 } 460 461 else /* 阴历转阳历 */ 462 { 463 if (!IsInteger(form_jisuan.nyear.value) || !IsInteger(form_jisuan.nmonth.value) || !IsInteger(form_jisuan.nday.value)) return alert("请输入合法农历年月日数值"); 464 LunarYear = parseInt(form_jisuan.nyear.value); 465 LunarMonth = parseInt(form_jisuan.nmonth.value); 466 LunarDate = parseInt(form_jisuan.nday.value); 467 468 if ( LunarYear < FIRSTYEAR || LunarYear >= LASTYEAR ) return alert("请输入1936-2031有效年份"); 469 470 y = LunarYear - FIRSTYEAR ; 471 im = LunarCal[y].Intercalation; 472 lm = LunarMonth; 473 474 if ( lm < 0 ) 475 { 476 if ( lm != -im ) 477 return alert(请输入有效月份); 478 } 479 else if ( lm < 1 || lm > 12 ) return alert(请输入有效月份); 480 481 if ( im != 0 ) 482 { 483 if ( lm > im ) 484 lm++; 485 else if ( lm == -im ) 486 lm = im + 1; 487 } 488 lm--; 489 490 if ( LunarDate > LunarCal[y].MonthDays[lm] + 29 ) 491 return alert("农历日期不正确"); 492 493 494 acc = 0; 495 for ( i=0; i < lm;i++) { 496 497 acc+= LunarCal[y].MonthDays[i] + 29; 498 499 500 } 501 502 acc +=LunarCal[y].BaseDays + LunarDate; 503 504 505 506 leap = GetLeap( LunarYear ); 507 508 509 for ( i=13; i>=0; i-- ) { 510 511 if ( acc > SolarDays[leap*14+i] ) 512 break; 513 } 514 SolarDate = acc - SolarDays[leap*14 + i] ; 515 516 517 518 if ( i <= 11 ) 519 { 520 521 SolarYear = LunarYear; 522 SolarMonth = i + 1; 523 } 524 else 525 { 526 527 SolarYear = LunarYear + 1; 528 SolarMonth = i - 11; 529 } 530 531 532 leap = GetLeap( SolarYear ); 533 y = SolarYear - FIRSTYEAR; 534 535 //acc = SolarDays[leap][SolarMonth-1] + SolarDate; 536 acc = SolarDays[leap*14 + SolarMonth-1] + SolarDate; 537 538 weekday = ( acc + LunarCal[y].BaseWeekday ) % 7; 539 kc = acc + LunarCal[y].BaseKanChih; 540 kan = kc % 10; 541 chih = kc % 12; 542 document.getElementById("ddd1").innerHTML="阳历为:"+ SolarYear + "年" + SolarMonth + "月" + SolarDate + "日"; 543 //alert("阳历为:"+ SolarYear + "年" + SolarMonth + "月" + SolarDate + "日" ); 544 545 return 0; 546 }//else结束 547 548 } 549 550 /* 闰年, 返回 0 平年, 1 闰年 */ 551 function GetLeap( year ) 552 { 553 if ( year % 400 == 0 ) 554 return 1; 555 else if ( year % 100 == 0 ) 556 return 0; 557 else if ( year % 4 == 0 ) 558 return 1; 559 else 560 return 0; 561 } 562 563 function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) { 564 this.BaseDays = d; /* 1 月 1 日到正月初一的累计日 */ 565 this.Intercalation = i; /* 闰月月份. 0==此年沒有闰月 */ 566 this.BaseWeekday = w; /* 此年 1 月 1 日为星期减 1 */ 567 this.BaseKanChih = k; /* 此年 1 月 1 日之干支序号减 1 */ 568 this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此农历年每月之大小, 0==小月(29日), 1==大月(30日) */ 569 } 570 571 //--> 572 573 574 //<!-- 575 576 577 function IsInteger(string ,sign) 578 { 579 var integer; 580 if ((sign!=null) && (sign!='-') && (sign!='+')) 581 { 582 alert('IsInter(string,sign)的参数出错:nsign为null或"-"或"+"'); 583 return false; 584 } 585 integer = parseInt(string); 586 if (isNaN(integer)) 587 { 588 return false; 589 } 590 else if (integer.toString().length==string.length) 591 { 592 if ((sign==null) || (sign=='-' && integer<0) || (sign=='+' && integer>0)) 593 { 594 return true; 595 } 596 else 597 return false; 598 } 599 else 600 return false; 601 } 602 603 //--></SCRIPT> 604 605 </body> 606 </html>
如需copy,则复制下面源码即可
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Cache-Control" content="no-transform" /> <meta http-equiv="Cache-Control" content="no-siteapp" /> </head> <body> <div class="wrapper"> <div class="plt"> <div class="viewbox"> <div class="title"> <h2>阴历阳历互转 公历农历转换器</h2></div> <div class="info"><small>一般意义上讲,阴历即是农历,阳历即是公历。</small></div> <FORM name="form_jisuan"> <div class="inform center"> <font color="#ff0000">农历</font>:<select name="nyear" class="zbslt"> <option value="1950" >1950</option> <option value="1951" >1951</option> <option value="1952" >1952</option> <option value="1953" >1953</option> <option value="1954" >1954</option> <option value="1955" >1955</option> <option value="1956" >1956</option> <option value="1957" >1957</option> <option value="1958" >1958</option> <option value="1959" >1959</option> <option value="1960" >1960</option> <option value="1961" >1961</option> <option value="1962" >1962</option> <option value="1963" >1963</option> <option value="1964" >1964</option> <option value="1965" >1965</option> <option value="1966" >1966</option> <option value="1967" >1967</option> <option value="1968" >1968</option> <option value="1969" >1969</option> <option value="1970" >1970</option> <option value="1971" >1971</option> <option value="1972" >1972</option> <option value="1973" >1973</option> <option value="1974" >1974</option> <option value="1975" >1975</option> <option value="1976" >1976</option> <option value="1977" >1977</option> <option value="1978" >1978</option> <option value="1979" >1979</option> <option value="1980" >1980</option> <option value="1981" >1981</option> <option value="1982" >1982</option> <option value="1983" >1983</option> <option value="1984" >1984</option> <option value="1985" >1985</option> <option value="1986" >1986</option> <option value="1987" >1987</option> <option value="1988" >1988</option> <option value="1989" >1989</option> <option value="1990" >1990</option> <option value="1991" >1991</option> <option value="1992" >1992</option> <option value="1993" >1993</option> <option value="1994" >1994</option> <option value="1995" >1995</option> <option value="1996" >1996</option> <option value="1997" >1997</option> <option value="1998" selected>1998</option> <option value="1999" >1999</option> <option value="2000" >2000</option> <option value="2001" >2001</option> <option value="2002" >2002</option> <option value="2003" >2003</option> <option value="2004" >2004</option> <option value="2005" >2005</option> <option value="2006" >2006</option> <option value="2007" >2007</option> <option value="2008" >2008</option> <option value="2009" >2009</option> <option value="2010" >2010</option> <option value="2011" >2011</option> <option value="2012" >2012</option> <option value="2013" >2013</option> <option value="2014" >2014</option> <option value="2015" >2015</option> <option value="2016" >2016</option> <option value="2017" >2017</option> <option value="2018" >2018</option> <option value="2019" >2019</option> <option value="2020" >2020</option> <option value="2021" >2021</option> </select> 年 <select name="nmonth" class="zbslt"> <option value="1" >1</option> <option value="2" >2</option> <option value="3" selected>3</option> <option value="4" >4</option> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> <option value="11" >11</option> <option value="12" >12</option> </select> 月 <select name="nday" class="zbslt"> <option value="1" >1</option> <option value="2" >2</option> <option value="3" >3</option> <option value="4" >4</option> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> <option value="11" >11</option> <option value="12" >12</option> <option value="13" >13</option> <option value="14" >14</option> <option value="15" >15</option> <option value="16" >16</option> <option value="17" >17</option> <option value="18" >18</option> <option value="19" >19</option> <option value="20" >20</option> <option value="21" >21</option> <option value="22" >22</option> <option value="23" >23</option> <option value="24" >24</option> <option value="25" >25</option> <option value="26" >26</option> <option value="27" selected>27</option> <option value="28" >28</option> <option value="29" >29</option> <option value="30" >30</option> </select> 日 <input type="hidden" name="nongli" value="农历" /> <input type="button" value="转为阳历" onClick="CalConv(1);" class="zbbtn2"> <div id="ddd1" class="red" align="center"></div> </div> <div class="inform center"> <font color="#ff0000">公历</font>:<select name="yyear" class="zbslt"> <option value="1950" >1950</option> <option value="1951" >1951</option> <option value="1952" >1952</option> <option value="1953" >1953</option> <option value="1954" >1954</option> <option value="1955" >1955</option> <option value="1956" >1956</option> <option value="1957" >1957</option> <option value="1958" >1958</option> <option value="1959" >1959</option> <option value="1960" >1960</option> <option value="1961" >1961</option> <option value="1962" >1962</option> <option value="1963" >1963</option> <option value="1964" >1964</option> <option value="1965" >1965</option> <option value="1966" >1966</option> <option value="1967" >1967</option> <option value="1968" >1968</option> <option value="1969" >1969</option> <option value="1970" >1970</option> <option value="1971" >1971</option> <option value="1972" >1972</option> <option value="1973" >1973</option> <option value="1974" >1974</option> <option value="1975" >1975</option> <option value="1976" >1976</option> <option value="1977" >1977</option> <option value="1978" >1978</option> <option value="1979" >1979</option> <option value="1980" >1980</option> <option value="1981" >1981</option> <option value="1982" >1982</option> <option value="1983" >1983</option> <option value="1984" >1984</option> <option value="1985" >1985</option> <option value="1986" >1986</option> <option value="1987" >1987</option> <option value="1988" >1988</option> <option value="1989" >1989</option> <option value="1990" >1990</option> <option value="1991" >1991</option> <option value="1992" >1992</option> <option value="1993" >1993</option> <option value="1994" >1994</option> <option value="1995" >1995</option> <option value="1996" >1996</option> <option value="1997" >1997</option> <option value="1998" selected>1998</option> <option value="1999" >1999</option> <option value="2000" >2000</option> <option value="2001" >2001</option> <option value="2002" >2002</option> <option value="2003" >2003</option> <option value="2004" >2004</option> <option value="2005" >2005</option> <option value="2006" >2006</option> <option value="2007" >2007</option> <option value="2008" >2008</option> <option value="2009" >2009</option> <option value="2010" >2010</option> <option value="2011" >2011</option> <option value="2012" >2012</option> <option value="2013" >2013</option> <option value="2014" >2014</option> <option value="2015" >2015</option> <option value="2016" >2016</option> <option value="2017" >2017</option> <option value="2018" >2018</option> <option value="2019" >2019</option> <option value="2020" >2020</option> <option value="2021" >2021</option> </select> 年 <select name="ymonth" class="zbslt"> <option value="1" >1</option> <option value="2" >2</option> <option value="3" selected>3</option> <option value="4" >4</option> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> <option value="11" >11</option> <option value="12" >12</option> </select> 月 <select name="yday" class="zbslt"> <option value="1" >1</option> <option value="2" >2</option> <option value="3" >3</option> <option value="4" >4</option> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> <option value="11" >11</option> <option value="12" >12</option> <option value="13" >13</option> <option value="14" >14</option> <option value="15" >15</option> <option value="16" >16</option> <option value="17" >17</option> <option value="18" >18</option> <option value="19" >19</option> <option value="20" >20</option> <option value="21" >21</option> <option value="22" >22</option> <option value="23" >23</option> <option value="24" >24</option> <option value="25" >25</option> <option value="26" >26</option> <option value="27" selected>27</option> <option value="28" >28</option> <option value="29" >29</option> <option value="30" >30</option> <option value="31" >31</option> </select> 日 <input type="hidden" name="gongli" value="公历" /> <input type="button" value="转为阴历" onClick="CalConv(0);" class="zbbtn2"> <div id="ddd2" class="red" align="center"></div> </div> </form> </div><!-- /viewbox --> </div><!-- //plt --> </div> <!-- /wrapper --> <SCRIPT language=JavaScript> function CalConv(M) { FIRSTYEAR = 1936; LASTYEAR = 2031; LunarCal = [ new tagLunarCal(23, 3, 2, 17, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ), /* 1936 */ new tagLunarCal( 41, 0, 4, 23, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), new tagLunarCal( 30, 7, 5, 28, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), new tagLunarCal( 49, 0, 6, 33, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), new tagLunarCal( 38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 1940 */ new tagLunarCal( 26, 6, 2, 44, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), new tagLunarCal( 45, 0, 3, 49, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 35, 0, 4, 54, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 24, 4, 5, 59, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1944 */ new tagLunarCal( 43, 0, 0, 5, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ), new tagLunarCal( 32, 0, 1, 10, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), new tagLunarCal( 21, 2, 2, 15, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), new tagLunarCal( 40, 0, 3, 20, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), /* 1948 */ new tagLunarCal( 28, 7, 5, 26, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 47, 0, 6, 31, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 36, 0, 0, 36, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 26, 5, 1, 41, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), /* 1952 */ new tagLunarCal( 44, 0, 3, 47, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1 ), new tagLunarCal( 33, 0, 4, 52, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), new tagLunarCal( 23, 3, 5, 57, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), new tagLunarCal( 42, 0, 6, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), /* 1956 */ new tagLunarCal( 30, 8, 1, 8, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 48, 0, 2, 13, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 38, 0, 3, 18, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 27, 6, 4, 23, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 1960 */ new tagLunarCal( 45, 0, 6, 29, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 35, 0, 0, 34, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), new tagLunarCal( 24, 4, 1, 39, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), new tagLunarCal( 43, 0, 2, 44, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), /* 1964 */ new tagLunarCal( 32, 0, 4, 50, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), new tagLunarCal( 20, 3, 5, 55, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), new tagLunarCal( 39, 0, 6, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 29, 7, 0, 5, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 1968 */ new tagLunarCal( 47, 0, 2, 11, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 36, 0, 3, 16, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ), new tagLunarCal( 26, 5, 4, 21, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1 ), new tagLunarCal( 45, 0, 5, 26, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1972 */ new tagLunarCal( 33, 0, 0, 32, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1 ), new tagLunarCal( 22, 4, 1, 37, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), new tagLunarCal( 41, 0, 2, 42, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ), new tagLunarCal( 30, 8, 3, 47, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ), /* 1976 */ new tagLunarCal( 48, 0, 5, 53, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1 ), new tagLunarCal( 37, 0, 6, 58, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 27, 6, 0, 3, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ), new tagLunarCal( 46, 0, 1, 8, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 1980 */ new tagLunarCal( 35, 0, 3, 14, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 ), new tagLunarCal( 24, 4, 4, 19, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ), new tagLunarCal( 43, 0, 5, 24, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ), new tagLunarCal( 32, 10, 6, 29, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ), /* 1984 */ new tagLunarCal( 50, 0, 1, 35, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), new tagLunarCal( 39, 0, 2, 40, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1 ), new tagLunarCal( 28, 6, 3, 45, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 ), new tagLunarCal( 47, 0, 4, 50, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 1988 */ new tagLunarCal( 36, 0, 6, 56, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ), new tagLunarCal( 26, 5, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1 ), new tagLunarCal( 45, 0, 1, 6, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 ), new tagLunarCal( 34, 0, 2, 11, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 ), /* 1992 */ new tagLunarCal( 22, 3, 4, 17, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), new tagLunarCal( 40, 0, 5, 22, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), new tagLunarCal( 30, 8, 6, 27, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1 ), new tagLunarCal( 49, 0, 0, 32, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 ), /* 1996 */ new tagLunarCal( 37, 0, 2, 38, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ), new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 1999 */ new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 2000 */ new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ), new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 2004 */ new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ), new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 2008 */ new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 2012 */ new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ), new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 2016 */ new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ), new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 2020 */ new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ), new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 2024 */ new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ), new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ), new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 2028 */ new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ), new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ), new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ]; /* 西曆年每月之日數 */ SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; /* 西曆年每月之累積日數, 平年與閏年 */ SolarDays = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ]; AnimalIdx = ["馬 ", "羊 ", "猴 ", "雞 ", "狗 ", "豬 ", "鼠 ", "牛 ", "虎 ", "兔 ", "龍 ", "蛇 " ]; LocationIdx = [ "南", "東", "北", "西" ]; if (M==0) { //阳历到阴历 if (!IsInteger(form_jisuan.yyear.value) || !IsInteger(form_jisuan.ymonth.value) || !IsInteger(form_jisuan.yday.value)) return alert("请输入合法阳历年月日数值"); SolarYear = parseInt(form_jisuan.yyear.value); SolarMonth = parseInt(form_jisuan.ymonth.value); SolarDate = parseInt(form_jisuan.yday.value); if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return alert("请输入1936-2031有效年份"); sm = SolarMonth - 1; if ( sm < 0 || sm > 11 ) return alert(请输入有效月份); leap = GetLeap( SolarYear ); if ( sm == 1 ) d = leap + 28; else d = SolarCal[sm]; if ( SolarDate < 1 || SolarDate > d ) return 3; y = SolarYear - FIRSTYEAR; acc = SolarDays[ leap*14 + sm ] + SolarDate; kc = acc + LunarCal[y].BaseKanChih; Kan = kc % 10; Chih = kc % 12; Location = LocationIdx[kc % 4]; Age = kc % 60; if ( Age < 22 ) Age = 22 - Age; else Age = 82 - Age; Age =Age + 3; if (Age < 10) Age=Age+60; Animal = AnimalIdx[ Chih ]; if ( acc <= LunarCal[y].BaseDays ) { y--; LunarYear = SolarYear - 1; leap = GetLeap( LunarYear ); sm += 12; acc = SolarDays[leap*14 + sm] + SolarDate; } else LunarYear = SolarYear; l1 = LunarCal[y].BaseDays; for ( i=0; i<13; i++ ) { l2 = l1 + LunarCal[y].MonthDays[i] + 29; if ( acc <= l2 ) break; l1 = l2; } LunarMonth = i + 1; LunarDate = acc - l1; im = LunarCal[y].Intercalation; if ( im != 0 && LunarMonth > im ) { LunarMonth--; if ( LunarMonth == im ) LunarMonth = -im; } if ( LunarMonth > 12 ) LunarMonth -= 12; document.getElementById("ddd2").innerHTML="农历为:"+ LunarYear + "年" + LunarMonth + "月" + LunarDate + "日"; //alert("农历为:"+ LunarYear + "年" + LunarMonth + "月" + LunarDate + "日" ); return 0; } else /* 阴历转阳历 */ { if (!IsInteger(form_jisuan.nyear.value) || !IsInteger(form_jisuan.nmonth.value) || !IsInteger(form_jisuan.nday.value)) return alert("请输入合法农历年月日数值"); LunarYear = parseInt(form_jisuan.nyear.value); LunarMonth = parseInt(form_jisuan.nmonth.value); LunarDate = parseInt(form_jisuan.nday.value); if ( LunarYear < FIRSTYEAR || LunarYear >= LASTYEAR ) return alert("请输入1936-2031有效年份"); y = LunarYear - FIRSTYEAR ; im = LunarCal[y].Intercalation; lm = LunarMonth; if ( lm < 0 ) { if ( lm != -im ) return alert(请输入有效月份); } else if ( lm < 1 || lm > 12 ) return alert(请输入有效月份); if ( im != 0 ) { if ( lm > im ) lm++; else if ( lm == -im ) lm = im + 1; } lm--; if ( LunarDate > LunarCal[y].MonthDays[lm] + 29 ) return alert("农历日期不正确"); acc = 0; for ( i=0; i < lm;i++) { acc+= LunarCal[y].MonthDays[i] + 29; } acc +=LunarCal[y].BaseDays + LunarDate; leap = GetLeap( LunarYear ); for ( i=13; i>=0; i-- ) { if ( acc > SolarDays[leap*14+i] ) break; } SolarDate = acc - SolarDays[leap*14 + i] ; if ( i <= 11 ) { SolarYear = LunarYear; SolarMonth = i + 1; } else { SolarYear = LunarYear + 1; SolarMonth = i - 11; } leap = GetLeap( SolarYear ); y = SolarYear - FIRSTYEAR; //acc = SolarDays[leap][SolarMonth-1] + SolarDate; acc = SolarDays[leap*14 + SolarMonth-1] + SolarDate; weekday = ( acc + LunarCal[y].BaseWeekday ) % 7; kc = acc + LunarCal[y].BaseKanChih; kan = kc % 10; chih = kc % 12; document.getElementById("ddd1").innerHTML="阳历为:"+ SolarYear + "年" + SolarMonth + "月" + SolarDate + "日"; //alert("阳历为:"+ SolarYear + "年" + SolarMonth + "月" + SolarDate + "日" ); return 0; }//else结束 } /* 闰年, 返回 0 平年, 1 闰年 */ function GetLeap( year ) { if ( year % 400 == 0 ) return 1; else if ( year % 100 == 0 ) return 0; else if ( year % 4 == 0 ) return 1; else return 0; } function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) { this.BaseDays = d; /* 1 月 1 日到正月初一的累计日 */ this.Intercalation = i; /* 闰月月份. 0==此年沒有闰月 */ this.BaseWeekday = w; /* 此年 1 月 1 日为星期减 1 */ this.BaseKanChih = k; /* 此年 1 月 1 日之干支序号减 1 */ this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此农历年每月之大小, 0==小月(29日), 1==大月(30日) */ } //--> //<!-- function IsInteger(string ,sign) { var integer; if ((sign!=null) && (sign!='-') && (sign!='+')) { alert('IsInter(string,sign)的参数出错:nsign为null或"-"或"+"'); return false; } integer = parseInt(string); if (isNaN(integer)) { return false; } else if (integer.toString().length==string.length) { if ((sign==null) || (sign=='-' && integer<0) || (sign=='+' && integer>0)) { return true; } else return false; } else return false; } //--></SCRIPT> </body> </html>