help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Exception dates in diary?


From: Edward M. Reingold
Subject: Re: Exception dates in diary?
Date: 19 Jan 2008 18:17:31 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

>>>>> "RAL" == Ross A Laird <ross@rosslaird.info> writes:

    RAL> I teach a class on Monday nights, and there are sometimes holiday
    RAL> Mondays when we skip class. In my diary file, I have this for the
    RAL> class schedule (eg):

    RAL> %%(and (= 1 (calendar-day-of-week date)) (diary-block 01 07 2008 03
    RAL> 10 2008)) 18:30-21:30 Class

    RAL> How do I modify this so that I can add the exception dates and have
    RAL> the calendar not show a class on a holiday?

Here is what I use (to get the effect you want) for my recycling dates and
payroll deposits; my diary has the entries

     &%%(recycling) Skokie recycling pickup
     &%%(let* ((month (extract-calendar-month date))
              (day (extract-calendar-day date))
               (year (extract-calendar-year date))
               (last (calendar-last-day-of-month month year))
               (dayname (calendar-day-of-week date)))
          (or (and (= day last) (memq dayname '(1 2 3 4 5)))
              (and (or (= day (1- last)) (= day (- last 2)))
                   (= dayname 5)))) 8am Print IIT/NWU pay stubs


and I have the following defined in my .emacs (this stuff could be in the
diary file also, but then it would be redefined wach time the diary is
examined):

(defun h-days (year);; Holidays that defer recycling and paychecks
  (list (calendar-absolute-from-gregorian (list 1 1 year));; New Year
        (calendar-dayname-on-or-before 1;; Monday
          (calendar-absolute-from-gregorian (list 5 31 year)));; Memorial Day
        (calendar-absolute-from-gregorian (list 7 4 year));; July 4
        (calendar-nth-named-absday 1 1 9 year);; Labor Day
        (calendar-nth-named-absday 4 4 11 year);; Thanksgiving
        (calendar-absolute-from-gregorian (list 12 31 year));; Christmas 
        ))

(defun recycle-date (d)
  ;; True if absolute date d should be a recycling date
  (let* ((diff (- d (calendar-absolute-from-gregorian
                     (list 6 30 2003)))));; first recycyling pickup
    (and (>= diff 0) (zerop (% diff 14)))))

(defun recycling ()
  (let* ((month (extract-calendar-month date))
         (day (extract-calendar-day date))
         (year (extract-calendar-year date))
         (a (calendar-absolute-from-gregorian date))
         (h (h-days year)))
    (or (and (recycle-date a) (not (memq a h)))
        (and (recycle-date (1- a)) (memq (1- a) h)))))



-- 

Professor Edward M. Reingold                Email: reingold@iit.edu
Department of Computer Science              Voice: (312) 567-3309
Illinois Institute of Technology            Fax:   (312) 567-5067
Stuart Building, 228F
10 West 31st Street
Chicago, IL  60616-3729  U.S.A.


reply via email to

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