Add ivritmon built-in function.

This commit is contained in:
Dianne Skoll
2025-12-22 11:11:18 -05:00
parent 18c4ed1c6d
commit 5118ccd120
6 changed files with 109 additions and 4 deletions

View File

@@ -171,7 +171,7 @@
"dusk" "easterdate" "escape" "eval" "evaltrig" "filedate" "filedatetime"
"filedir" "filename" "getenv" "hebdate" "hebday" "hebmon" "hebyear" "hex"
"hour" "htmlescape" "htmlstriptags" "iif" "index" "isany" "isconst" "isdst"
"isleap" "isomitted" "language" "localtoutc" "lower" "max"
"isleap" "isomitted" "ivritmon" "language" "localtoutc" "lower" "max"
"mbasc" "mbindex" "mbstrlen" "mbsubstr" "min"
"minsfromutc" "minute" "mon" "monnum" "moondate" "moondatetime"
"moonphase" "moonrise" "moonrisedir" "moonset" "moonsetdir" "moontime"

View File

@@ -6961,6 +6961,11 @@ Thus, hebday('1993/04/12') returns 21.
Returns the name of the Hebrew month corresponding to \fIdate\fR.
For example, hebmon('1993/04/12') returns "Nisan".
.TP
.B ivritmon(d_date)
Returns the name of the Hebrew month corresponding to \fIdate\fR,
in UTF-8-encoded Hebrew script. For example, ivritmon('1993/04/12')
returns "ניסן".
.TP
.B hebyear(d_date)
Returns the Hebrew year corresponding to \fIdate\fR. For example,
hebyear('1993/04/12') returns 5753.

View File

@@ -133,6 +133,7 @@ static int FIsconst (expr_node *, Value *, Value *, int *);
static int FIsdst (func_info *);
static int FIsleap (func_info *);
static int FIsomitted (func_info *);
static int FIvritmon (func_info *);
static int FLanguage (func_info *);
static int FLocalToUTC (func_info *);
static int FLower (func_info *);
@@ -318,6 +319,7 @@ BuiltinFunc Func[] = {
{ "isdst", 0, 2, 0, FIsdst, NULL },
{ "isleap", 1, 1, 1, FIsleap, NULL },
{ "isomitted", 1, 1, 0, FIsomitted, NULL },
{ "ivritmon", 1, 1, 0, FIvritmon, NULL },
{ "language", 0, 0, 1, FLanguage, NULL },
{ "localtoutc", 1, 1, 1, FLocalToUTC, NULL },
{ "lower", 1, 1, 1, FLower, NULL },
@@ -3060,6 +3062,26 @@ static int FHebmon(func_info *info)
return RetStrVal(HebMonthName(m, y), info);
}
static int FIvritmon(func_info *info)
{
int y, m, d, v;
if (!HASDATE(ARG(0))) return E_BAD_TYPE;
v = DATEPART(ARG(0));
if (v == CacheHebDse) {
m = CacheHebMon;
y = CacheHebYear;
} else {
DSEToHeb(v, &y, &m, &d);
CacheHebDse = v;
CacheHebYear = y;
CacheHebMon = m;
CacheHebDay = d;
}
return RetStrVal(IvritMonthName(m, y), info);
}
static int FHebyear(func_info *info)
{
int y, m, d, v;

View File

@@ -66,8 +66,20 @@ static char const *HebMonthNames[] = {
"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};

View File

@@ -16685,6 +16685,32 @@ hebdate(1, "Elul") => 1991-08-11
hebdate(1, "אלול") => 1991-08-11
hebdate(1, "Adar") => 1992-03-06
hebdate(1, "אדר") => 1992-03-06
hebmon(1991-09-09) => "Tishrey"
ivritmon(1991-09-09) => "תשרי"
hebmon(1991-10-09) => "Heshvan"
ivritmon(1991-10-09) => "חשוון"
hebmon(1991-11-08) => "Kislev"
ivritmon(1991-11-08) => "כסלו"
hebmon(1991-12-08) => "Tevet"
ivritmon(1991-12-08) => "טבת"
hebmon(1992-01-06) => "Shvat"
ivritmon(1992-01-06) => "שבט"
hebmon(1992-02-05) => "Adar A"
ivritmon(1992-02-05) => "אדר א'"
hebmon(1992-03-06) => "Adar B"
ivritmon(1992-03-06) => "אדר ב'"
hebmon(1991-03-16) => "Nisan"
ivritmon(1991-03-16) => "ניסן"
hebmon(1991-04-15) => "Iyar"
ivritmon(1991-04-15) => "אייר"
hebmon(1991-05-14) => "Sivan"
ivritmon(1991-05-14) => "סיוון"
hebmon(1991-06-13) => "Tamuz"
ivritmon(1991-06-13) => "תמוז"
hebmon(1991-07-12) => "Av"
ivritmon(1991-07-12) => "אב"
hebmon(1991-08-11) => "Elul"
ivritmon(1991-08-11) => "אלול"
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
@@ -16706,7 +16732,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: 106555
Total expression node evaluations: 106607
Test 2
@@ -24684,6 +24710,7 @@ isconst
isdst
isleap
isomitted
ivritmon
language
localtoutc
lower

View File

@@ -1814,6 +1814,45 @@ SET a hebdate(1, "אלול")
SET a hebdate(1, "Adar")
SET a hebdate(1, "אדר")
set a hebmon('1991-09-09')
set a ivritmon('1991-09-09')
set a hebmon('1991-10-09')
set a ivritmon('1991-10-09')
set a hebmon('1991-11-08')
set a ivritmon('1991-11-08')
set a hebmon('1991-12-08')
set a ivritmon('1991-12-08')
set a hebmon('1992-01-06')
set a ivritmon('1992-01-06')
set a hebmon('1992-02-05')
set a ivritmon('1992-02-05')
set a hebmon('1992-03-06')
set a ivritmon('1992-03-06')
set a hebmon('1991-03-16')
set a ivritmon('1991-03-16')
set a hebmon('1991-04-15')
set a ivritmon('1991-04-15')
set a hebmon('1991-05-14')
set a ivritmon('1991-05-14')
set a hebmon('1991-06-13')
set a ivritmon('1991-06-13')
set a hebmon('1991-07-12')
set a ivritmon('1991-07-12')
set a hebmon('1991-08-11')
set a ivritmon('1991-08-11')
DEBUG -x
# Don't want Remind to queue reminders
EXIT