Things will break, and APIs might change. Be cautious using this in production. Additionally, not all methods have been tested for accuracy.
zmanim.sql is a partial SQL port of the KosherJava library.
The dialect used is MySQL.
Run the scripts in the context of your DB.
In general, pure static KosherJava methods were converted to deterministic functions.
E.g., in JewishDate:
privatestaticintgetLastDayOfGregorianMonth(intmonth, intyear)was converted to:
CREATEFUNCTIONJewishDate_getLastDayOfGregorianMonth(month INTEGER UNSIGNED, year INTEGER UNSIGNED) RETURNS INTEGER UNSIGNED
DETERMINISTICImpure instance methods were usually converted to stored procedures that return multiple out parameters,
with the out parameters corresponding to the instance methods that are mutated.
E.g., in JewishDate:
privatevoidabsDateToJewishDate()which uses instance property gregorianAbsDate and mutates instance properties jewishYear, jewishMonth, and jewishDay,
was converted to:
CREATE PROCEDURE JewishDate_absDateToJewishDate(gregorianAbsDate INTEGER UNSIGNED, OUT jewishYear INTEGER UNSIGNED,
OUT jewishMonth INTEGER UNSIGNED, OUT jewishDay INTEGER UNSIGNED)
DETERMINISTICSome helper procedures have been added to take the places of constructors and methods that only make sense in an instance context.
E.g. instead of the following:
Calendarcalendar = Calendar.getInstance();
calendar.set(2023, Calendar.DECEMBER, 31);
JewishDatejewishDate = newJewishDate(calendar);
intjewishYear = jewishDate.getJewishYear();
intjewishMonth = jewishDate.getJewishMonth();
intjewishDay = jewishDate.getJewishDayOfMonth();use the following:
CALL gregorian_date_to_jewish_date(2023, 12, 31, @jewishYear, @jewishMonth, @jewishDay);
select @jewishYear, @jewishMonth, @jewishDay;