Revision: ab6c1c08c88f
Author: Enrico Spinielli <
enrico.s...@gmail.com>
Date: Tue May 15 06:34:04 2012
Log: Fixed serious bug as per errata.
http://code.google.com/p/pycalcal/source/detail?r=ab6c1c08c88f
Modified:
/
calendrica-3.0.errata.cl
/pycalcal.nw
=======================================
--- /
calendrica-3.0.errata.cl Sun Nov 22 09:38:14 2009
+++ /
calendrica-3.0.errata.cl Tue May 15 06:34:04 2012
@@ -476,6 +476,32 @@
(< (- u l) (hr (/ 1 60))))))
(if (< rise (1+ t)) (standard-from-universal rise location) bogus)))
+;; new (Errata '11:53pm, June 22, 2011'), serious error
+(defun possible-hebrew-days (h-month h-day)
+ ;; TYPE (hebrew-month hebrew-day) -> list-of-weekdays
+ ;; Possible days of week
+ (let* ((h-date0 (hebrew-date 5 nisan 1))
+ ;; leap year with full pattern
+ (h-year (if (> h-month elul) 6 5))
+ (h-date (hebrew-date h-year h-month h-day))
+ (n (- (fixed-from-hebrew h-date)
+ (fixed-from-hebrew h-date0)))
+ (basic (list tuesday thursday saturday))
+ (extra
+ (cond
+ ((and (= h-month marheshvan) (= h-day 30))
+ nil)
+ ((and (= h-month kislev) (< h-day 30))
+ (list monday wednesday friday))
+ ((and (= h-month kislev) (= h-day 30))
+ (list monday))
+ ((member h-month (list tevet shevat))
+ (list sunday monday))
+ ((and (= h-month adar) (< h-day 30))
+ (list sunday monday))
+ (t (list sunday)))))
+ (shift-days (append basic extra) n)))
+
;;;============================= History
=======================================
;; 2009/11/19 Enrico Spinielli
;; Extracted changes/enhancements from
=======================================
--- /pycalcal.nw Mon Oct 17 08:46:31 2011
+++ /pycalcal.nw Tue May 15 06:34:04 2012
@@ -2370,7 +2370,7 @@
"""Shift each weekday on list l by cap_Delta days."""
return map(lambda x: day_of_week_from_fixed(x + cap_Delta), l)
-# see lines 1962-1984 in
calendrica-3.0.cl
+# see lines 480-504 in
calendrica-3.0.errata.cl
def `possible_hebrew_days(h_month, h_day):
"""Return a list of possible days of week for Hebrew day h_day
and Hebrew month h_month."""
@@ -2378,21 +2378,23 @@
h_year = 6 if (h_month > ELUL) else 5
h_date = hebrew_date(h_year, h_month, h_day)
n = fixed_from_hebrew(h_date) - fixed_from_hebrew(h_date0)
- tue_thu_sat = [TUESDAY, THURSDAY, SATURDAY]
-
- if (h_day == 30) and (h_month in [MARHESHVAN, KISLEV]):
- sun_wed_fri = []
- elif (h_month == KISLEV):
- sun_wed_fri = [SUNDAY, WEDNESDAY, FRIDAY]
+ basic = [TUESDAY, THURSDAY, SATURDAY]
+
+ if (h_month == MARHESHVAN) and (h_day == 30):
+ extra = []
+ elif (h_month == KISLEV) and (h_day < 30):
+ extra = [MONDAY, WEDNESDAY, FRIDAY]
+ elif (h_month == KISLEV) and (h_day == 30):
+ extra = [MONDAY]
+ elif h_month in [TEVET, SHEVAT]:
+ extra = [SUNDAY, MONDAY]
+ elif (h_month == ADAR) and (h_day < 30):
+ extra = [SUNDAY, MONDAY]
else:
- sun_wed_fri = [SUNDAY]
-
- mon = [MONDAY] if h_month in [KISLEV, TEVET, SHEVAT, ADAR] else [ ]
-
- ell = tue_thu_sat
- ell.extend(sun_wed_fri)
- ell.extend(mon)
- return shift_days(ell, n)
+ extra = [SUNDAY]
+
+ basic.extend(extra)
+ return shift_days(basic, n)
<<hebrew calendar unit test>>=
class `HebrewSmokeTestCase(unittest.TestCase):