Allow use of Hebrew month spellings in hebdate()

This commit is contained in:
Dianne Skoll
2025-12-22 10:55:46 -05:00
parent 62e1a467f5
commit 18c4ed1c6d
5 changed files with 118 additions and 10 deletions

View File

@@ -6919,14 +6919,19 @@ jahrzeits (anniversaries of deaths) and smachot (joyous occasions.)
.PP
.B THE HEBREW YEAR
.PP
The Hebrew year has 12 months, alternately 30 and 29 days long. The months
are: Tishrey, Heshvan, Kislev, Tevet, Shvat, Adar, Nisan, Iyar, Sivan, Tamuz,
Av and Elul. In Biblical times, the year started in Nisan, but Rosh Hashana
(Jewish New Year) is now celebrated on the 1st and 2nd of Tishrey.
The Hebrew year has 12 months, alternately 30 and 29 days long. The
months are: Tishrey, Heshvan, Kislev, Tevet, Shvat, Adar, Nisan, Iyar,
Sivan, Tamuz, Av and Elul. If you are in a UTF-8 locale, you can
\fIalso\fR use the UTF-8-encoded Hebrew spellings for the month names,
namely:
.PP
תשרי, חשוון, כסלו, טבת, שבט, אדר, ניסן, אייר, סיוון, תמוז, אב, אלול.
.PP
In a cycle of 19 years, there are 7 leap years, being years 3, 6, 8, 11,
14, 17 and 19 of the cycle. In a leap year, an extra month of 30 days
is added before Adar. The two Adars are called Adar A and Adar B.
is added before Adar. The two Adars are called Adar A and Adar B,
or in Hebrew, 'אדר א and 'אדר ב.
.PP
For certain religious reasons, the year cannot start on a Sunday, Wednesday
or Friday. To adjust for this, a day is taken off Kislev or added to Heshvan.
@@ -6969,7 +6974,8 @@ corresponding to the Hebrew date.
The \fIday\fR parameter can range from 1 to 30, and specifies the day of
the Hebrew month. The \fIhebmon\fR parameter is a string that must name
one of the Hebrew months specified above. Note that the month must be spelled
out in full, and use the English transliteration shown previously. You can
out in full, and use either the English transliteration shown previously, or
the Hebrew spelling \fIencoded in UTF-8\fR. You can
also specify "Adar A" and "Adar B." Month names are not case-sensitive.
.PP
The \fIyrstart\fR parameter can either be a \fBDATE\fR or an \fBINT\fR. If

View File

@@ -65,6 +65,10 @@ static char const *HebMonthNames[] = {
"Tishrey", "Heshvan", "Kislev", "Tevet", "Shvat", "Adar A", "Adar B",
"Nisan", "Iyar", "Sivan", "Tamuz", "Av", "Elul", "Adar"};
static char const *IvritMonthNames[] = {
"תשרי", "חשוון", "כסלו", "טבת", "שבט", "אדר א'", "אדר ב'",
"ניסן", "אייר", "סיוון", "תמוז", "אב", "אלול", "אדר" };
static char MaxMonLen[] = {
30, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29};
@@ -245,14 +249,22 @@ int HebNameToNum(char const *mname)
int i;
int m=-1;
for (i=0; i<14; i++)
for (i=0; i<14; i++) {
if (!StrCmpi(mname, HebMonthNames[i])) {
m = i;
break;
}
}
if (m == -1) {
for (i=0; i<14; i++) {
if (!StrCmpi(mname, IvritMonthNames[i])) {
m = i;
break;
}
}
}
return m;
}
}
/***************************************************************/
/* */
@@ -270,6 +282,22 @@ char const *HebMonthName(int m, int y)
else return HebMonthNames[m];
}
/***************************************************************/
/* */
/* IvritMonthname */
/* */
/* Convert a Hebrew month's number to its name in Hebrew */
/* script, given the year. */
/* */
/***************************************************************/
char const *IvritMonthName(int m, int y)
{
if (m != ADARA && m != ADARB) return IvritMonthNames[m];
if (!HebIsLeap[(y-1)%19]) return IvritMonthNames[ADAR];
else return IvritMonthNames[m];
}
/***************************************************************/
/* */
/* GetValidHebDate */

View File

@@ -175,6 +175,7 @@ int UserFuncExists (char const *fn);
void DSEToHeb (int dse, int *hy, int *hm, int *hd);
int HebNameToNum (char const *mname);
char const *HebMonthName (int m, int y);
char const *IvritMonthName (int m, int y);
int HebToDSE (int hy, int hm, int hd);
int GetValidHebDate (int yin, int min, int din, int adarbehave, int *mout, int *dout, int yahr);
int GetNextHebrewDate (int dsestart, int hm, int hd, int yahr, int adarbehave, int *ans);

View File

@@ -16657,6 +16657,34 @@ mbchar(0, 120) => Number too low
../tests/test.rem(1767): mbchar(): Number too low
mbchar(120, 0) => Number too low
../tests/test.rem(1768): mbchar(): Number too low
hebdate(1, "Tishrey") => 1991-09-09
hebdate(1, "תשרי") => 1991-09-09
hebdate(1, "Heshvan") => 1991-10-09
hebdate(1, "חשוון") => 1991-10-09
hebdate(1, "Kislev") => 1991-11-08
hebdate(1, "כסלו") => 1991-11-08
hebdate(1, "Tevet") => 1991-12-08
hebdate(1, "טבת") => 1991-12-08
hebdate(1, "Shvat") => 1992-01-06
hebdate(1, "שבט") => 1992-01-06
hebdate(1, "Adar A") => 1992-02-05
hebdate(1, "אדר א'") => 1992-02-05
hebdate(1, "Adar B") => 1992-03-06
hebdate(1, "אדר ב'") => 1992-03-06
hebdate(1, "Nisan") => 1991-03-16
hebdate(1, "ניסן") => 1991-03-16
hebdate(1, "Iyar") => 1991-04-15
hebdate(1, "אייר") => 1991-04-15
hebdate(1, "Sivan") => 1991-05-14
hebdate(1, "סיוון") => 1991-05-14
hebdate(1, "Tamuz") => 1991-06-13
hebdate(1, "תמוז") => 1991-06-13
hebdate(1, "Av") => 1991-07-12
hebdate(1, "אב") => 1991-07-12
hebdate(1, "Elul") => 1991-08-11
hebdate(1, "אלול") => 1991-08-11
hebdate(1, "Adar") => 1992-03-06
hebdate(1, "אדר") => 1992-03-06
Variable hash table statistics:
Entries: 100146; Buckets: 87719; Non-empty Buckets: 66303
Maxlen: 5; Minlen: 0; Avglen: 1.142; Stddev: 0.878; Avg nonempty len: 1.510
@@ -16678,7 +16706,7 @@ Expression nodes high-water: 302076
Expression nodes leaked: 0
Parse level high-water: 34
Max expr node evaluations per line: 2001
Total expression node evaluations: 106471
Total expression node evaluations: 106555
Test 2

View File

@@ -1769,6 +1769,51 @@ set a mbchar(120, 0)
# Make sure trailing space doesn't cause a diagnostic.
set a "foo"
# Hebrew dates
SET a hebdate(1, "Tishrey")
SET a hebdate(1, "תשרי")
SET a hebdate(1, "Heshvan")
SET a hebdate(1, "חשוון")
SET a hebdate(1, "Kislev")
SET a hebdate(1, "כסלו")
SET a hebdate(1, "Tevet")
SET a hebdate(1, "טבת")
SET a hebdate(1, "Shvat")
SET a hebdate(1, "שבט")
SET a hebdate(1, "Adar A")
SET a hebdate(1, "אדר א'")
SET a hebdate(1, "Adar B")
SET a hebdate(1, "אדר ב'")
SET a hebdate(1, "Nisan")
SET a hebdate(1, "ניסן")
SET a hebdate(1, "Iyar")
SET a hebdate(1, "אייר")
SET a hebdate(1, "Sivan")
SET a hebdate(1, "סיוון")
SET a hebdate(1, "Tamuz")
SET a hebdate(1, "תמוז")
SET a hebdate(1, "Av")
SET a hebdate(1, "אב")
SET a hebdate(1, "Elul")
SET a hebdate(1, "אלול")
SET a hebdate(1, "Adar")
SET a hebdate(1, "אדר")
DEBUG -x
# Don't want Remind to queue reminders
EXIT