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

这个公历转农历输出结果不对,明显是十月十七,输出的确实十月十八 #10

Open
mickeyzhou opened this issue Nov 24, 2018 · 2 comments

Comments

@mickeyzhou
Copy link

No description provided.

@li2go
Copy link

li2go commented Dec 27, 2018

用的时候记得归零时分秒

@alanchanzm
Copy link

alanchanzm commented Sep 20, 2019

如果是 89 ~ 91 年的数据 需要处理一下夏令时

var _getTime = function(date) {
  const RE = //;
  let timestamp = date.getTime();
  if (RE.test(date.toString())) {
    timestamp += 1000 * 60 * 60;
  }
  return timestamp;
};

/**
 * 农历转阳历
 * lunarToSolar({}),或者lunarToSolar(year, month, day, leap)
 */
_chineseLunar.lunarToSolar = function(year, month, day, leap) {
  //  省略……
  var time = _getTime(solar) + (day - 1) * 24 * 60 * 60 * 1000;
  return new Date(time);
};

//计算公历两个日期之差
var _solarDiff = function(left, right, interval) {
  var span = _getTime(left) - _getTime(right); //相差毫秒
  //  省略……
};

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