emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Last workday of the month


From: Chris Maier
Subject: [Orgmode] Last workday of the month
Date: Sat, 30 Oct 2010 14:55:57 -0400

I'm trying to come up with a sexp diary entry that shows my payday,
which is the last weekday of the month, in my Org agenda.  I've tried
to adapt the example given in the Emacs manual and this is what I came
up with:

%%(let ((month (car date))
        (day (cadr date))
        (dayname (calendar-day-of-week date)))
    (or
     ;; months with 31 days
     (and (memq month '(1 3 5 7 8 10 12))
             (or (and (= day 31)
                      (memq dayname '(1 2 3 4 5)))
                 (and (memq day '(29 30))
                      (= dayname 5))))
     ;; months with 30 days
     (and (memq month '(4 6 9 11))
          (or (and (= day 30)
                   (memq dayname '(1 2 3 4 5)))
              (and (memq day '(28 29))
                   (= dayname 5))))
     ;; February (the weird one)
     (and (= month 2)
          (or (and (memq day '(28 29))
                   (memq dayname '(1 2 3 4 5)))
              (and (memq day '(26 27 28))
                   (= dayname 5)))))) Chris' Paycheck Deposited

It appears to work so far.  However, I'm certain there's got to be a
more concise way of coding this, but I can't seem to find any
pre-existing calendar functions that might help.  Am I missing
something?

To make this even better, is there some way to consult another file of
diary entries containing all the holidays at my workplace, so the
diary entry would show up on the last weekday of the month that is not
a company holiday?

Thanks!

Chris



reply via email to

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