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

@@ -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);