[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real u

From: Alf-Ivar Holm
Subject: Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update
Date: Thu, 07 Dec 2006 13:11:03 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)

address@hidden (Edward M. Reingold) writes:

>>>>>> "AH" == Alf-Ivar Holm <address@hidden> writes:
>     AH> I should point out as this is titled a hack and I do not have have a
>     AH> test suite I will not guarantee that it works in all environments, BUT
>     AH> I have used it with extensive diary usage, and with the use of
>     AH> Norwegian names, holidays, and calendar set up without any problems
>     AH> (except for eventual changes in functions/variables when a new emacs
>     AH> arrived, e.g. v. 22) for 10 years.  Despite what the calendar author
> How do you know that the holidays are correct when the calendar has
> more than 3 months?  Do you have a way to check, say, the dates of
> lunar phases, Easter, Chinese New Year, Yom Kippur, Islamic New
> Year, solstices/equinoxes?  You will see SOME holidays (or diary
> entries) but not all that apply to the months displayed.

I admit that I don't use many of those, but I have got Easter, which I
had to modify to fit to the Norwegian Easter celebration¹.  I have got
this in the sitestart.el, again based on your code:

(defun local-holiday-easter-etc ()
  "List of dates related to Easter in Norway, as visible in calendar window."
 (if (and (> displayed-month 5))
     nil;; Ash Wednesday, Good Friday, and Easter are not visible.
   (let* ((century (1+ (/ displayed-year 100)))
          (shifted-epact        ;; Age of moon for April 5...
           (% (+ 14 (* 11 (% displayed-year 19));; Nicaean rule
                 (-           ;; ...corrected for the Gregorian century rule
                  (/ (* 3 century) 4))
                 (/    ;; ...corrected for Metonic cycle inaccuracy.
                  (+ 5 (* 8 century)) 25)
                 (* 30 century));;              Keeps value positive.
          (adjusted-epact       ;;  Adjust for 29.5 day month.
           (if (or (= shifted-epact 0)
                   (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
               (1+ shifted-epact)
          (paschal-moon       ;; Day after the full moon on or after March 21.
           (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
          (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
            (list (calendar-gregorian-from-absolute (- abs-easter 7))
            (list (calendar-gregorian-from-absolute (- abs-easter 3))
            (list (calendar-gregorian-from-absolute (- abs-easter 2))
            (list (calendar-gregorian-from-absolute abs-easter)
                  "1. påskedag")
            (list (calendar-gregorian-from-absolute (+ abs-easter 1))
                  "2. påskedag")
            (list (calendar-gregorian-from-absolute (+ abs-easter 39))
            (list (calendar-gregorian-from-absolute (+ abs-easter 49))
                  "1. pinsedag")
            (list (calendar-gregorian-from-absolute (+ abs-easter 50))
                  "2. pinsedag")))
           (filter-visible-calendar-holidays mandatory)))
     (if all-christian-calendar-holidays
         (setq output-list
                (filter-visible-calendar-holidays optional)

(eval-after-load "holidays"
  '(fset 'holiday-easter-etc 'local-holiday-easter-etc))

And this works as expected (by me), e.g. the Easter of 2007 is shown
here, with the cursor on Easter Sunday ("1. påskedag"):

> The code won't generally die ungracefully, but the the output will
> NOT be right.

Yes, that is of course harder to debug.


¹) We only got 2 and half work day each Easter, with the day off on
the day after Easter Sunday as well.  We basically don't work at all
at Easter.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]