Hi!

It seems there's a bug in the handling of jahrzeits in *regular* Adar
(despite all the attention paid to correctly handling Adar A and Adar
B ;) .

Attached a couple of patches, one which adds a test displaying the bug
(and can be used as a regression test once the fix is applied), and
the other which actually fixes it. Feel free to squash the patches
together or apply them in reverse order if you prefer.

Thanks for creating and sharing remind -- it's a great tool!

Thanks!
Dov
From ffc1590917a01d983c3433a27c0997c7aa512877 Mon Sep 17 00:00:00 2001
From: Dov Feldstern <[email protected]>
Date: Tue, 11 Dec 2018 16:06:38 +0200
Subject: [PATCH 1/2] Add test displaying bug in handling of *regular* Adar in
 jahrzeits

---
 tests/test.cmp | 12 ++++++++++++
 tests/test.rem |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/tests/test.cmp b/tests/test.cmp
index 4613153..6793b3a 100644
--- a/tests/test.cmp
+++ b/tests/test.cmp
@@ -1150,6 +1150,18 @@ Global Full OMITs (16 of maximum allowed 500):
 	2010-12-27
 Global Partial OMITs (1 of maximum allowed 366):
 	12-25
+# Regression test for bugfix in Hebrew calendar Adar jahrzeit
+[_i(14, "Adar", today(), 5761)] MSG Purim
+today() => 1991-02-16
+Entering UserFN _i(14, "Adar", 1991-02-16, 5761)
+x => 14
+y => "Adar"
+z => 1991-02-16
+a => 5761
+hebdate(14, "Adar", 1991-02-16, 5761) => 1991-02-28
+trigger(1991-02-28) => "28 February 1991"
+Leaving UserFN _i() => "28 February 1991"
+../tests/test.rem(317): Trig = Thursday, 28 February, 1991
 
 
 Test 2
diff --git a/tests/test.rem b/tests/test.rem
index 6d2f1f9..7703b0a 100644
--- a/tests/test.rem
+++ b/tests/test.rem
@@ -313,6 +313,8 @@ OMIT December 25 MSG X
 # Next should give a parse error
 OMIT 26 Dec 2010 THROUGH 27 Dec 2010 MSG This is not legal
 OMIT DUMP
+# Regression test for bugfix in Hebrew calendar Adar jahrzeit
+[_i(14, "Adar", today(), 5761)] MSG Purim
 __EOF__
 REM This line should not even be seen
 And you can put whatever you like here.
-- 
2.19.1

From 292c8b01434096f7cf3014d49005cde9cb3bc68a Mon Sep 17 00:00:00 2001
From: Dov Feldstern <[email protected]>
Date: Tue, 11 Dec 2018 16:14:07 +0200
Subject: [PATCH 2/2] Fix bug in handling of jahrzeit in *regular* Adar

Until now, jahrzeits in "Adar A" or "Adar B" were handled correctly, but a
jahrzeit in just plain "Adar" raised an "Invalid Hebrew date" error.

I wasn't sure at first what the best way to fix this is, but I finally settled
on just updating the array returned by DaysInHebMonths() to include the days of
plain Adar at index 13. I think this makes sense, because (a) ComputeJahr()
appears quite happy to handle the m=13 case (as evidenced by the sanity check
  m < 0 || m > 13
), and (b) now, after the fix, the array returned by DaysInHebMonths()
corresponds to the MaxMonLen[] array in that they are both of the same length,
and with corresponding months.
---
 src/hbcal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/hbcal.c b/src/hbcal.c
index ba3e0dc..7a66b3d 100644
--- a/src/hbcal.c
+++ b/src/hbcal.c
@@ -138,8 +138,8 @@ int DaysInHebYear(int y)
 /***************************************************************/
 char const *DaysInHebMonths(int ylen)
 {
-    static char monlen[13] =
-    {30, 29, 30, 29, 30, 0, 29, 30, 29, 30, 29, 30, 29};
+    static char monlen[14] =
+    {30, 29, 30, 29, 30, 0, 29, 30, 29, 30, 29, 30, 29, 29};
 
 
     if (ylen > 355) {
-- 
2.19.1

_______________________________________________
Remind-fans mailing list
[email protected]
https://dianne.skoll.ca/mailman/listinfo/remind-fans
Remind is at https://dianne.skoll.ca/projects/remind/

Reply via email to