问题描述
解决方案
换了百度的新历转农历,应该是没有问题了,但是百度的没有农历转新历的功能,所以只好禁用农历下拉选择切换了,自己去这里更新下文件和代码
解决方案二:
页面显示js
function toCNNumber(v) {
var r = '', cn = 'O一二三四五六七八九十';
v = v.toString();
for (var i = 0; i < v.length; i++) r += cn.charAt(v.charAt(i));
return r;
}
var now = new Date(), y = now.getFullYear(), ba = 20/*取和当前时间相差前后20年*/;
var yOpts = '',cnyOpts='', mOpts = '', dOpts = '';
for (var i = y - 20, j = y + 20; i <= j; i++) {
cnyOpts += '<option value="' + i + '">' + toCNNumber(i) + '</option>';//汉字的年份
yOpts += '<option value="' + i + '">' + i + '</option>';
}
for (var i = 1, j = 12; i <= j; i++) mOpts += '<option value="' + i + '">' + i + '</option>';
for (var i = 1, j = 31; i <= j; i++) dOpts += '<option value="' + i + '">' + i + '</option>';
var stY = document.getElementById('stY'), stM = document.getElementById('stM'), stD = document.getElementById('stD'),
lstY = document.getElementById('lstY'), lstM = document.getElementById('lstM'), lstD = document.getElementById('lstD'),
etY = document.getElementById('etY'), etM = document.getElementById('etM'), etD = document.getElementById('etD'),
letY = document.getElementById('letY'), letM = document.getElementById('letM'), letD = document.getElementById('letD');
var lMons = '正二三四五六七八九十冬腊', lDays1 = '初十廿卅', lDays2 = '一二三四五六七八九十', v,ds;
//更新农历月份显示
for (var i = 0; i < 12; i++) {
v = parseInt(lstM.options[i].value) - 1;
lstM.options[i].text = letM.options[i].text = lMons.charAt(v) + '月';
}
//更新农历月份显示
for (var i = 0; i < 31; i++) {
v = parseInt(lstD.options[i].value);
if (v <= 10) ds = lDays1.charAt(0);
else ds = lDays1.charAt(parseInt(v.toString().charAt(0)));
lstD.options[i].text = letD.options[i].text = ds + lDays2.charAt((v - 1) % 10);
}
//下拉框更改事件,更新对应的农历新历日期
stY.onchange = stM.onchange = stD.onchange = lstY.onchange = lstM.onchange = lstD.onchange =
etY.onchange = etM.onchange = etD.onchange = letY.onchange = letM.onchange = letD.onchange = function () {
var sign = this.id.indexOf('l') == 0;//是否农历日期框变化
var idPrefix = /[a-z]+/.exec(this.id)[0];//获取起始或者截止前缀
var dateStr = window[idPrefix + 'Y'].value + '/' + window[idPrefix + 'M'].value + '/' + window[idPrefix + 'D'].value;
var date = new Date(dateStr);//生成日期对象,注意这里,如果日期选择错误,js会自动更正为最新日期,如2015/2/31,会变为2015/3/3
//////////////
if ((date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()) != dateStr) {//和源字符不一样说明日期选错,重置select为新生成日期或者自己修改这里alert提示错误return返回也行
window[idPrefix + 'Y'].value = date.getFullYear();
window[idPrefix + 'M'].value = date.getMonth() + 1;
window[idPrefix + 'D'].value = date.getDate();
}
/////////////
var rstDate = CalConvert(date, !sign, true);//执行农历新历转换
if (rstDate) {//转换成功,更新对应的农历或者新历下拉框
if (sign) idPrefix = idPrefix.replace('l', '');
else idPrefix = 'l' + idPrefix;
window[idPrefix + 'Y'].value = rstDate.getFullYear();
window[idPrefix + 'M'].value = rstDate.getMonth() + 1;
window[idPrefix + 'D'].value = rstDate.getDate();
}
//计算时间差
var stDate = new Date(stY.value + '/' + stM.value + '/' + stD.value);
var etDate = new Date(etY.value + '/' + etM.value + '/' + etD.value);
var s = Math.abs(etDate.getTime() - stDate.getTime()) ;//总秒数
var y = Math.floor(s / (365*24*3600*1000));//多少年
var m = Math.floor(s / (31*24*3600*1000));//多少月
var w = Math.floor(s / (7*24*3600*1000));//多少周
var d = Math.floor(s / (24*3600*1000));//多少天
var h = Math.floor(s / (3600*1000));//多少小时
var i = Math.floor(s / (60*1000));//多少分钟
var s = Math.floor(s / 1000);//多少秒
document.getElementById('sRsty').innerHTML = y + '年' ;
document.getElementById('sRstm').innerHTML = m + '月' ;
document.getElementById('sRstw').innerHTML = w + '周' ;
document.getElementById('sRstd').innerHTML = d + '天' ;
document.getElementById('sRsth').innerHTML = h + '小时';
document.getElementById('sRsti').innerHTML = i + '分钟' ;
document.getElementById('sRsts').innerHTML = s + '秒';
}
//设置新历为当前日期
stY.value = etY.value = y;
stM.value = etM.value = now.getMonth() + 1;
stD.value = etD.value = now.getDate();
//触发onchange事件设置对应农历日期
stD.onchange();
etD.onchange();
解决方案三:
阴阳历转换js
// JavaScript阳历,阴历相互转换源代码
// @date 2010-06-01
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日) */
}
// 闰年判断.返回1 或 0
function GetLeap(year) {
return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 1 : 0;
}
// 主类入口
// @param {Date} new Date(y,m,d)
// @param {Boolean} false: 农历-->公历 true: 公历 --> 农历,默认false
// @returnDate {Boolean} false: 返回字符串 true: 返回Date对象,默认false
// @return {String} 见example
// @example
// CalConvert(new Date(2010,3,19), false) 即农历的四月十九转为公历 结果为 2010-06-01
// CalConvert(new Date(2010,5,1), true) 即公历的6月1日转为农历 结果为 2010年四月十九
//
function CalConvert(date, sign,returnDate) {
// 日期上下限
FIRSTYEAR = 1996;
LASTYEAR = 2036;
// 返回结果值
RESULT = 0;
// 对照表
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 = ["南", "東", "北", "西"];
var func = sign ? function (d) {
function getBit(m, n) { return (m >> n) & 1; }
var mons = "正二三四五六七八九十冬腊", Cal = [0x41A95, 0xD4A, 0xDA5, 0x20B55, 0x56A, 0x7155B, 0x25D, 0x92D, 0x5192B, 0xA95, 0xB4A, 0x416AA, 0xAD5, 0x90AB5, 0x4BA, 0xA5B, 0x60A57, 0x52B, 0xA93, 0x40E95];
var total, m, n, k, isEnd = false, t = d.getYear();
if (t < 1900) t += 1900;
total = (t - 2001) * 365 + Math.floor((t - 2001) / 4) + [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334][d.getMonth()] + d.getDate() - 23;
if (d.getYear() % 4 == 0 && d.getMonth() > 1) total++;
for (m = 0; m < 1000; m++) {
k = (Cal[m] < 0xfff) ? 11 : 12;
for (n = k; n >= 0; n--) {
if (total <= 29 + getBit(Cal[m], n)) {
isEnd = true;
break;
}
total = total - 29 - getBit(Cal[m], n);
}
if (isEnd) break;
}
var cYear = 2001 + m, cMonth = k - n + 1;
if (k == 12) {
if (cMonth == Math.floor(Cal[m] / 0x10000) + 1)
cMonth = 1 - cMonth;
if (cMonth > Math.floor(Cal[m] / 0x10000) + 1)
cMonth--;
}
var t = "";
if (cMonth < 1) {
t += "闰";
t += mons.charAt(-cMonth - 1);
}
else t += mons.charAt(cMonth - 1);
t += "月";
t += (total < 11) ? "初" : ((total < 20) ? "十" : ((total < 30) ? "廿" : "卅"));
if (total % 10 != 0 || total == 10) t += "一二三四五六七八九十".charAt((total - 1) % 10);
return returnDate ? new Date(cYear+'/'+cMonth+'/'+total) : cYear + '年' + t;
} : function (d) {
var LunarYear = d.getFullYear(),
LunarMonth = d.getMonth() + 1,
LunarDate = d.getDate(),
acc = 0,
leap, SolarDate, y, im, lm;
if (LunarYear < FIRSTYEAR || LunarYear >= LASTYEAR) {
alert('只处理1936 - 2036有效年份');
return false;
}
y = LunarYear - FIRSTYEAR;
im = LunarCal[y].Intercalation;
lm = LunarMonth;
if (lm < 0) {
if (lm != -im) {
alert('月份无效');
return false;
}
}
else if (lm < 1 || lm > 12) {
alert('月份无效');
return false;
}
if (im != 0) {
if (lm > im) {
lm++;
} else if (lm == -im) {
lm = im + 1;
}
}
lm--;
if (LunarDate > LunarCal[y].MonthDays[lm] + 29) {
alert('农历日期不正确');
return false;
}
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 * 14 + SolarMonth - 1] + SolarDate;
weekday = (acc + LunarCal[y].BaseWeekDay) % 7;
kc = acc + LunarCal[y].BaseKanChih;
kan = kc % 10;
chih = kc % 12;
return returnDate ? new Date(SolarYear + '/' + SolarMonth + '/' + SolarDate) : SolarYear + '-' + SolarMonth + '-' + SolarDate;
}
return func(date);
}
时间: 2024-09-14 08:44:52