UNPKG

@calj.net/jdates

Version:

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

54 lines (53 loc) 1.28 kB
export function isDate(date) { return (date !== null && typeof date === "object" && date.constructor.name === "Date"); } export 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 || (DayOfWeek = {})); export class JDate { hdn; 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")}`; } }