--- hebcal.h 2004-02-29 23:15:33.000000000 -0500 +++ hebcal.h 2004-12-21 01:01:41.000000000 -0500 @@ -57,6 +57,7 @@ printOmer_sw, printHebDates_sw, printSomeHebDates_sw, + printMolad_sw, sedraAllWeek_sw, sedrot_sw, noGreg_sw, --- common.h 2002-09-13 15:17:05.000000000 -0400 +++ common.h 2004-12-21 01:29:42.000000000 -0500 @@ -38,7 +38,7 @@ int hour, chalakim; } molad_t; -molad_t molad(int, int); +molad_t get_molad(int, int); date_t abs2hebrew(long); long hebrew2abs(date_t); int days_in_heb_year(int); --- start.c 2004-07-14 21:53:09.000000000 -0400 +++ start.c 2004-12-21 14:28:55.000000000 -0500 @@ -352,7 +352,7 @@ Getopt(argc, argv, "", 1); while (EOF != - (option = Getopt(argc, argv, "acC:dDef:hHI:il:L:m:orsStTwxyY:z:Z:8", 0))) + (option = Getopt(argc, argv, "acC:dDef:hHI:il:L:m:MorsStTwxyY:z:Z:8", 0))) { switch ((char) option) { @@ -424,6 +424,9 @@ if (!(sscanf(Optarg, "%d", &havdalah_minutes) == 1)) die("unable to read havdalah_minutes argument: %s", Optarg); break; + case 'M': /* print the molad */ + printMolad_sw = 1; + break; case 'o': /* print the omer */ printOmer_sw = 1; break; --- hebcal.c 2004-02-24 23:48:54.000000000 -0500 +++ hebcal.c 2004-12-21 16:03:50.000000000 -0500 @@ -35,6 +35,7 @@ #include "rise.h" #include "sedra.h" #include "format.h" +#include "greg.h" #define LANGUAGE(str) (ashkenazis_sw && (str)[1] ? ((str)[1]) : ((str)[0])) @@ -42,7 +43,7 @@ int ashkenazis_sw, candleLighting_sw, euroDates_sw, hebrewDates_sw, inputFile_sw, - israel_sw, latlong_sw, printOmer_sw, sedraAllWeek_sw, sedrot_sw, noGreg_sw, + israel_sw, latlong_sw, printOmer_sw, printMolad_sw, sedraAllWeek_sw, sedrot_sw, noGreg_sw, printHebDates_sw, printSomeHebDates_sw, noHolidays_sw, tabs_sw, weekday_sw, suppress_rosh_chodesh_sw, yearDigits_sw, yahrtzeitFile_sw, DST_scheme, DST_value; int iso8859_8_sw; @@ -311,7 +312,9 @@ year_t theYear; char *omerStr ; int omer, day_of_week, returnedMask, DST; - int omer_today, sedra_today, candle_today, holidays_today; + int omer_today, sedra_today, candle_today, holidays_today, molad_today; + molad_t moladNext; + int monthNext; todayHeb = abs2hebrew (todayAbs); todayGreg = abs2greg (todayAbs); @@ -342,6 +345,10 @@ (returnedMask & YOM_TOV_ENDS)); holidays_today = holip && (!noHolidays_sw || (returnedMask & USER_EVENT)); + molad_today = printMolad_sw && + (day_of_week == SAT) && + (todayHeb.dd >= 23 && todayHeb.dd <= 29) && + (todayHeb.mm != ELUL); /* no birkat hachodesh before rosh hashana */ if (printHebDates_sw || (printSomeHebDates_sw && @@ -413,6 +420,21 @@ day_of_week, todayGreg, DST); } + /* Print Molad */ + if (molad_today) + { + PrintGregDate (todayGreg); + monthNext = (todayHeb.mm == MONTHS_IN_HEB(todayHeb.yy) ? 1 : todayHeb.mm + 1); + moladNext = get_molad(todayHeb.yy, monthNext); + printf ("Molad %s: %s, %d minutes and %d chalakim after %d %s\n", + hMonths[LEAP_YR_HEB(todayHeb.yy)][monthNext].name[0], + ShortDayNames[dayOfWeek(abs2greg(moladNext.day))], + (int) moladNext.chalakim / 18, + moladNext.chalakim % 18, + (moladNext.hour > 12 ? moladNext.hour - 12 : moladNext.hour), + (moladNext.hour > 12 ? "PM" : "AM") + ); + } incHebGregDate (&todayHeb, &todayGreg, &todayAbs, &day_of_week, &theYear); --- common.c 2004-02-29 22:03:08.000000000 -0500 +++ common.c 2004-12-21 17:53:51.000000000 -0500 @@ -156,19 +156,21 @@ -#if 0 - /* returns day of week, hours and chalakim of specified molad. */ -molad_t molad( int year, int m) +molad_t get_molad( int year, int month) { molad_t retMolad; - long yearl, m_elapsed, p_elapsed, h_elapsed, parts; + long yearl, m_elapsed, p_elapsed, h_elapsed, parts, m_adj; + + m_adj = (long) month; + m_adj -= 7; + if (m_adj < 0) m_adj += MONTHS_IN_HEB(year); yearl = (long) year; - m_elapsed = (long) m + + m_elapsed = m_adj + 235L * ((yearl - 1L) / 19L) + 12L * ((yearl - 1L) % 19) + ((((yearl - 1L) % 19L) * 7) + 1L) / 19L; @@ -177,7 +179,8 @@ h_elapsed = 5L + (12L * m_elapsed) + 793L * (m_elapsed / 1080L) + - p_elapsed / 1080L; + p_elapsed / 1080L - + 6L; parts = (p_elapsed % 1080) + 1080 * (h_elapsed % 24); @@ -188,7 +191,6 @@ return retMolad; } -#endif date_t abs2hebrew( long d )