Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

计算到1986年-1991年之间的时候,计算的day不是整数。是小数 #22

Open
HappyYawen opened this issue Aug 17, 2018 · 3 comments

Comments

@HappyYawen
Copy link

计算到1986年-1991年之间的时候,计算的day不是整数。是小数。

@liubeibei125
Copy link

同遇到 你怎么解决的

@liubeibei125
Copy link

lunarCalendar.js 268行改为 var end = between>0 ? Math.ceil(between) : lunarYearDays.yearDays - Math.abs(Math.ceil(between));

@longbill
Copy link

longbill commented Jan 11, 2023

/**
 * 两个公历日期之间的天数
 */
function getDaysBetweenSolar(year,month,day, year1,month1,day1){
	var date = new Date(year,month,day).getTime();
	var date1 = new Date(year1,month1,day1).getTime();
	return Math.round((date1-date) / 86400000);
};

我发现是这个函数最后返回的时候有问题,整除86400000有可能由于夏令时等原因导致小数出现。加一个四舍五入(Math.round)就行了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants