[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));; ...by 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.
30))
(adjusted-epact ;; Adjust for 29.5 day month.
(if (or (= shifted-epact 0)
(and (= shifted-epact 1) (< 10 (% displayed-year 19))))
(1+ shifted-epact)
shifted-epact))
(paschal-moon ;; Day after the full moon on or after March 21.
(- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
adjusted-epact))
(abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
(mandatory
(list
(list (calendar-gregorian-from-absolute (- abs-easter 7))
"Palmesøndag")
(list (calendar-gregorian-from-absolute (- abs-easter 3))
"Skjærtorsdag")
(list (calendar-gregorian-from-absolute (- abs-easter 2))
"Langfredag")
(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))
"Himmelspretten")
(list (calendar-gregorian-from-absolute (+ abs-easter 49))
"1. pinsedag")
(list (calendar-gregorian-from-absolute (+ abs-easter 50))
"2. pinsedag")))
(output-list
(filter-visible-calendar-holidays mandatory)))
(if all-christian-calendar-holidays
(setq output-list
(append
(filter-visible-calendar-holidays optional)
output-list)))
output-list)))
(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"):
http://pogostick.net/~affi/Screendump-Calendar-Easter2007.png
> The code won't generally die ungracefully, but the the output will
> NOT be right.
Yes, that is of course harder to debug.
Affi
¹) 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.
- Calendar hack: Displaying ISO weeks, update for emacs 22, Alf-Ivar Holm, 2006/12/01
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, Glenn Morris, 2006/12/01
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, Richard Stallman, 2006/12/02
- Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Alf-Ivar Holm, 2006/12/06
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Edward M. Reingold, 2006/12/06
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update,
Alf-Ivar Holm <=
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Edward M. Reingold, 2006/12/07
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Richard Stallman, 2006/12/08
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Ed Reingold, 2006/12/08
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Alf-Ivar Holm, 2006/12/08
- Re: Calendar hack: Displaying ISO weeks, update for emacs 22, the real update, Richard Stallman, 2006/12/07