UNPKG

lunar-typescript-optimize

Version:

A TypeScript library for Solar and Chinese Lunar calendar calculations, with optimized build and browser compatibility

45 lines (44 loc) 934 B
import { LunarUtil } from "./LunarUtil.mjs"; import { NineStarUtil } from "./NineStarUtil.mjs"; export class NineStar { _index; static fromIndex(index) { return new NineStar(index); } constructor(index) { this._index = index; } getNumber() { return NineStarUtil.NUMBER[this._index]; } getColor() { return NineStarUtil.COLOR[this._index]; } getWuXing() { return NineStarUtil.WU_XING[this._index]; } getPosition() { return NineStarUtil.POSITION[this._index]; } getPositionDesc() { const v = LunarUtil.POSITION_DESC[this.getPosition()]; return v ? v : ""; } getIndex() { return this._index; } toString() { return this.getNumber(); } toFullString() { let s = this.getNumber(); s += this.getColor(); s += this.getWuXing(); s += " "; s += this.getPosition(); s += "("; s += this.getPositionDesc(); s += ")"; return s; } }