jewish-calendar
Version:
A comprehensive Jewish Calendar library for date conversion and calculations
40 lines (39 loc) • 1.07 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Molad = void 0;
const HOUR = 1080;
const AVG_MONTH = { days: 29, hours: 12, parts: 793 };
class Molad {
constructor(months) {
this.day = AVG_MONTH.days * months;
this.hour = AVG_MONTH.hours * months;
this.parts = AVG_MONTH.parts * months;
this.addMolad(2, 5, 204); // add molad of creation (molad tohu)
this.normalize();
}
addMolad(day, hour, parts) {
this.day += day;
this.hour += hour;
this.parts += parts;
}
normalize() {
this.hour += Math.floor(this.parts / HOUR);
this.parts = this.parts % HOUR;
this.day += Math.floor(this.hour / 24);
this.hour = this.hour % 24;
this.day = this.day % 7;
if (this.day === 0) {
this.day = 7;
}
}
getDay() {
return this.day;
}
getHour() {
return this.hour;
}
toString() {
return `${this.day} ${this.hour}:${this.parts}`;
}
}
exports.Molad = Molad;