Allow arg to easterdate() and orthodoxeaster() to be omitted, defaulting it to today().

This commit is contained in:
Dianne Skoll
2024-02-26 17:19:22 -05:00
parent 22ccce0934
commit 6b798d5f7c
2 changed files with 30 additions and 20 deletions

View File

@@ -3080,11 +3080,12 @@ will produce undefined results.
Returns the time of "civil twilight" on the specified \fIdate\fR. If Returns the time of "civil twilight" on the specified \fIdate\fR. If
\fIdate\fR is omitted, defaults to \fBtoday()\fR. \fIdate\fR is omitted, defaults to \fBtoday()\fR.
.TP .TP
.B easterdate(dqi_arg) .B easterdate([dqi_arg])
If \fIarg\fR is an \fBINT\fR, then returns the date of Easter Sunday If \fIarg\fR is an \fBINT\fR, then returns the date of Easter Sunday
for the specified year. If \fIarg\fR is a \fBDATE\fR or for the specified year. If \fIarg\fR is a \fBDATE\fR or
\fBDATETIME\fR, then returns the date of the next Easter Sunday on or \fBDATETIME\fR, then returns the date of the next Easter Sunday on or
after \fIarg\fR. (The time component of a datetime is ignored.) after \fIarg\fR. (The time component of a datetime is ignored.) If \fIarg\fR
is omitted, then it defaults to \fBtoday()\fR.
.RS .RS
.P .P
Note that \fBeasterdate\fR computes the Western Easter. For the Orthodox Note that \fBeasterdate\fR computes the Western Easter. For the Orthodox
@@ -3439,11 +3440,12 @@ the actual time, or a time supplied on the command line.
Returns a string that is the ordinal number \fInum\fR. For example, Returns a string that is the ordinal number \fInum\fR. For example,
\fBord(2)\fR returns "2nd", and \fBord(213)\fR returns "213th". \fBord(2)\fR returns "2nd", and \fBord(213)\fR returns "213th".
.TP .TP
.B orthodoxeaster(dqi_arg) .B orthodoxeaster([dqi_arg])
If \fIarg\fR is an \fBINT\fR, then returns the date of Orthodox Easter Sunday If \fIarg\fR is an \fBINT\fR, then returns the date of Orthodox Easter Sunday
for the specified year. If \fIarg\fR is a \fBDATE\fR or for the specified year. If \fIarg\fR is a \fBDATE\fR or
\fBDATETIME\fR, then returns the date of the next Orthodox Easter Sunday on or \fBDATETIME\fR, then returns the date of the next Orthodox Easter Sunday on or
after \fIarg\fR. (The time component of a datetime is ignored.) after \fIarg\fR. (The time component of a datetime is ignored.) If \fIarg\fR
is omitted, then it defaults to \fBtoday()\fR.
.RS .RS
.P .P
Note that \fBorthodoxeaster\fR computes the Orthodox Easter. For the Western Note that \fBorthodoxeaster\fR computes the Orthodox Easter. For the Western

View File

@@ -251,7 +251,7 @@ BuiltinFunc Func[] = {
{ "defined", 1, 1, 0, FDefined }, { "defined", 1, 1, 0, FDefined },
{ "dosubst", 1, 3, 0, FDosubst }, { "dosubst", 1, 3, 0, FDosubst },
{ "dusk", 0, 1, 0, FDusk }, { "dusk", 0, 1, 0, FDusk },
{ "easterdate", 1, 1, 0, FEasterdate }, { "easterdate", 0, 1, 0, FEasterdate },
{ "evaltrig", 1, 2, 0, FEvalTrig }, { "evaltrig", 1, 2, 0, FEvalTrig },
{ "filedate", 1, 1, 0, FFiledate }, { "filedate", 1, 1, 0, FFiledate },
{ "filedatetime", 1, 1, 0, FFiledatetime }, { "filedatetime", 1, 1, 0, FFiledatetime },
@@ -289,7 +289,7 @@ BuiltinFunc Func[] = {
{ "nonomitted", 2, NO_MAX, 0, FNonomitted }, { "nonomitted", 2, NO_MAX, 0, FNonomitted },
{ "now", 0, 0, 0, FNow }, { "now", 0, 0, 0, FNow },
{ "ord", 1, 1, 1, FOrd }, { "ord", 1, 1, 1, FOrd },
{ "orthodoxeaster",1, 1, 0, FOrthodoxeaster }, { "orthodoxeaster",0, 1, 0, FOrthodoxeaster },
{ "ostype", 0, 0, 1, FOstype }, { "ostype", 0, 0, 1, FOstype },
{ "pad", 3, 4, 1, FPad }, { "pad", 3, 4, 1, FPad },
{ "plural", 1, 3, 1, FPlural }, { "plural", 1, 3, 1, FPlural },
@@ -2364,13 +2364,17 @@ static int FEasterdate(func_info *info)
{ {
int y, m, d; int y, m, d;
int g, c, x, z, e, n; int g, c, x, z, e, n;
if (ARG(0).type == INT_TYPE) { if (Nargs == 0) {
y = ARGV(0); FromDSE(DSEToday, &y, &m, &d);
if (y < BASE) return E_2LOW; } else {
else if (y > BASE+YR_RANGE) return E_2HIGH; if (ARG(0).type == INT_TYPE) {
} else if (HASDATE(ARG(0))) { y = ARGV(0);
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */ if (y < BASE) return E_2LOW;
} else return E_BAD_TYPE; else if (y > BASE+YR_RANGE) return E_2HIGH;
} else if (HASDATE(ARG(0))) {
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */
} else return E_BAD_TYPE;
}
do { do {
g = (y % 19) + 1; /* golden number */ g = (y % 19) + 1; /* golden number */
@@ -2409,13 +2413,17 @@ static int FOrthodoxeaster(func_info *info)
{ {
int y, m, d; int y, m, d;
int a, b, c, dd, e, f, dse; int a, b, c, dd, e, f, dse;
if (ARG(0).type == INT_TYPE) { if (Nargs == 0) {
y = ARGV(0); FromDSE(DSEToday, &y, &m, &d);
if (y < BASE) return E_2LOW; } else {
else if (y > BASE+YR_RANGE) return E_2HIGH; if (ARG(0).type == INT_TYPE) {
} else if (HASDATE(ARG(0))) { y = ARGV(0);
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */ if (y < BASE) return E_2LOW;
} else return E_BAD_TYPE; else if (y > BASE+YR_RANGE) return E_2HIGH;
} else if (HASDATE(ARG(0))) {
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */
} else return E_BAD_TYPE;
}
do { do {
a = y % 4; a = y % 4;