UNPKG

@calj.net/jdates

Version:

The Jewish Dates library from https://CalJ.net

58 lines (57 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JDate = exports.DayOfWeek = exports.isDate = void 0; function isDate(date) { return (date !== null && typeof date === "object" && date.constructor.name === "Date"); } exports.isDate = isDate; var DayOfWeek; (function (DayOfWeek) { DayOfWeek[DayOfWeek["RISHON"] = 0] = "RISHON"; DayOfWeek[DayOfWeek["MONDAY"] = 1] = "MONDAY"; DayOfWeek[DayOfWeek["SHISHI"] = 5] = "SHISHI"; DayOfWeek[DayOfWeek["SHABBAT"] = 6] = "SHABBAT"; })(DayOfWeek = exports.DayOfWeek || (exports.DayOfWeek = {})); class JDate { constructor(param) { if (typeof param === "number") { this.hdn = param; } else { this.hdn = param.hdn; } } setHdn(hdn) { this.hdn = hdn; } lt(other) { return this.hdn < other.hdn; } eq(other) { return this.hdn === other.hdn; } lte(other) { return this.hdn <= other.hdn; } gt(other) { return this.hdn > other.hdn; } gte(other) { return this.hdn >= other.hdn; } minus(other) { return this.hdn - other.hdn; } getHdn() { return this.hdn; } getDayOfWeek() { return this.hdn % 7; } toString() { return `${this.getYear()}-${`${this.getMonth()}`.padStart(2, "0")}-${`${this.getDay()}`.padStart(2, "0")}`; } } exports.JDate = JDate;