fortel-ziweidoushu
Version:
紫微斗數排盤 Zi Wei Dou Shu
77 lines • 2.62 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DAY_TIME_GROUNDS = exports.DayTimeGround = void 0;
const ground_1 = require("./ground");
const utils_1 = require("./../utils");
const util_1 = __importDefault(require("util"));
class DayTimeGround {
index;
displayName;
ground;
hourStart;
hourEnd;
constructor(index, displayName, ground, hourStart, hourEnd) {
this.index = index;
this.displayName = displayName;
this.ground = ground;
this.hourStart = hourStart;
this.hourEnd = hourEnd;
}
toJSON() {
return this.displayName;
}
toString() {
return this.displayName;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-unused-vars
[util_1.default.inspect.custom](depth, opts) {
return this.toString();
}
static get(i) {
return DAY_TIME_GROUNDS[(0, utils_1.mod)(i, DAY_TIME_GROUNDS.length)];
}
static getByName(name) {
const target = DAY_TIME_GROUNDS.filter((dayTimeGround) => dayTimeGround.displayName === name)[0];
if (target) {
return target;
}
else {
throw new Error('Not found');
}
}
static getByStartHour(hour) {
const target = DAY_TIME_GROUNDS.filter((dayTimeGround) => dayTimeGround.hourStart === hour)[0];
if (target) {
return target;
}
else {
throw new Error('Not found');
}
}
static getByHour(hour) {
const target = DAY_TIME_GROUNDS.filter((dayTimeGround) => dayTimeGround.hourStart <= hour && hour < dayTimeGround.hourEnd)[0];
if (target) {
return target;
}
else {
throw new Error('Not found');
}
}
static values() {
return DAY_TIME_GROUNDS;
}
}
exports.DayTimeGround = DayTimeGround;
const DAY_TIME_GROUNDS = Object.freeze([
Object.freeze(new DayTimeGround(0, '早子時', ground_1.Ground.get(0), 0, 1)),
...ground_1.Ground.GROUNDS.slice(1).map((ground) => {
const i = ground.index;
return Object.freeze(new DayTimeGround(i, ground.displayName + '時', ground, -1 + i * 2, 1 + i * 2));
}),
Object.freeze(new DayTimeGround(12, '夜子時', ground_1.Ground.get(0), 23, 24)),
]);
exports.DAY_TIME_GROUNDS = DAY_TIME_GROUNDS;
//# sourceMappingURL=dayTimeGround.js.map