lunar-typescript-optimize
Version:
A TypeScript library for Solar and Chinese Lunar calendar calculations, with optimized build and browser compatibility
29 lines (28 loc) • 774 B
JavaScript
import { LunarUtil } from "./LunarUtil.mjs";
export class LiuYue {
_index;
_liuNian;
constructor(liuNian, index) {
this._liuNian = liuNian;
this._index = index;
}
getIndex() {
return this._index;
}
getMonthInChinese() {
return LunarUtil.MONTH[this._index + 1];
}
getGanZhi() {
const yearGanIndex = LunarUtil.find(this._liuNian.getGanZhi(), LunarUtil.GAN).index - 1;
const offset = [2, 4, 6, 8, 0][yearGanIndex % 5];
const gan = LunarUtil.GAN[(this._index + offset) % 10 + 1];
const zhi = LunarUtil.ZHI[(this._index + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12 + 1];
return gan + zhi;
}
getXun() {
return LunarUtil.getXun(this.getGanZhi());
}
getXunKong() {
return LunarUtil.getXunKong(this.getGanZhi());
}
}