@iro/calendar
Version:
lunar is a calendar library for Solar and Chinese Lunar.
41 lines • 1.35 kB
JavaScript
import { LunarUtil } from './LunarUtil';
var LiuYue = (function () {
function LiuYue(liuNian, index) {
this._liuNian = liuNian;
this._index = index;
}
LiuYue.prototype.getIndex = function () {
return this._index;
};
LiuYue.prototype.getMonthInChinese = function () {
return LunarUtil.MONTH[this._index + 1];
};
LiuYue.prototype.getGanZhi = function () {
var offset = 0;
var yearGan = this._liuNian.getGanZhi().substr(0, 1);
if ('甲' === yearGan || '己' === yearGan) {
offset = 2;
}
else if ('乙' === yearGan || '庚' === yearGan) {
offset = 4;
}
else if ('丙' === yearGan || '辛' === yearGan) {
offset = 6;
}
else if ('丁' === yearGan || '壬' === yearGan) {
offset = 8;
}
var gan = LunarUtil.GAN[(this._index + offset) % 10 + 1];
var zhi = LunarUtil.ZHI[(this._index + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12 + 1];
return gan + zhi;
};
LiuYue.prototype.getXun = function () {
return LunarUtil.getXun(this.getGanZhi());
};
LiuYue.prototype.getXunKong = function () {
return LunarUtil.getXunKong(this.getGanZhi());
};
return LiuYue;
}());
export { LiuYue };
//# sourceMappingURL=LiuYue.js.map