@iro/calendar
Version:
lunar is a calendar library for Solar and Chinese Lunar.
94 lines • 2.88 kB
JavaScript
import { LunarUtil } from './LunarUtil';
import { LiuNian } from './LiuNian';
import { XiaoYun } from './XiaoYun';
var DaYun = (function () {
function DaYun(yun, index) {
var lunar = yun.getLunar();
var birthYear = lunar.getSolar().getYear();
var year = yun.getStartSolar().getYear();
var startYear, startAge, endYear, endAge;
if (index < 1) {
startYear = birthYear;
startAge = 1;
endYear = year - 1;
endAge = year - birthYear;
}
else {
startYear = year + (index - 1) * 10;
startAge = startYear - birthYear + 1;
endYear = startYear + 9;
endAge = startAge + 9;
}
this._startYear = startYear;
this._endYear = endYear;
this._startAge = startAge;
this._endAge = endAge;
this._index = index;
this._yun = yun;
this._lunar = lunar;
}
DaYun.prototype.getStartYear = function () {
return this._startYear;
};
DaYun.prototype.getEndYear = function () {
return this._endYear;
};
DaYun.prototype.getStartAge = function () {
return this._startAge;
};
DaYun.prototype.getEndAge = function () {
return this._endAge;
};
DaYun.prototype.getIndex = function () {
return this._index;
};
DaYun.prototype.getLunar = function () {
return this._lunar;
};
DaYun.prototype.getGanZhi = function () {
if (this._index < 1) {
return '';
}
var offset = LunarUtil.getJiaZiIndex(this._lunar.getMonthInGanZhiExact());
offset += this._yun.isForward() ? this._index : -this._index;
var size = LunarUtil.JIA_ZI.length;
if (offset >= size) {
offset -= size;
}
if (offset < 0) {
offset += size;
}
return LunarUtil.JIA_ZI[offset];
};
DaYun.prototype.getXun = function () {
return LunarUtil.getXun(this.getGanZhi());
};
DaYun.prototype.getXunKong = function () {
return LunarUtil.getXunKong(this.getGanZhi());
};
DaYun.prototype.getLiuNian = function (n) {
if (n === void 0) { n = 10; }
if (this._index < 1) {
n = this._endYear - this._startYear + 1;
}
var l = [];
for (var i = 0; i < n; i++) {
l.push(new LiuNian(this, i));
}
return l;
};
DaYun.prototype.getXiaoYun = function (n) {
if (n === void 0) { n = 10; }
if (this._index < 1) {
n = this._endYear - this._startYear + 1;
}
var l = [];
for (var i = 0; i < n; i++) {
l.push(new XiaoYun(this, i, this._yun.isForward()));
}
return l;
};
return DaYun;
}());
export { DaYun };
//# sourceMappingURL=DaYun.js.map