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

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

Re: how to get calendar- for an offset day


From: Edward M. Reingold
Subject: Re: how to get calendar- for an offset day
Date: 18 Dec 2008 09:49:30 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

>>>>> "M" == Mirko  <mvukovic@nycap.rr.com> writes:

    M> Hi, For a personal log, I use the `calendar-current-date' function
    M> together with calendar-date-display-form to insert the current date
    M> into the diary.  But sometimes I am lazy, or I forget, and I need to
    M> insert yesterday's date into the calendar.

    M> I did not find anything in calendar.el (but I might have missed it).
    M> Any other options?

This suggests an improvement to calendar.el.  Change the function
calendar-current-date to have an optional OFFSET:

(defun calendar-current-date (&optional offset)
  "Return the current date in a list (month day year).
Optional OFFSET is number of days from current date."
  (let* ((now (decode-time)))
    (calendar-gregorian-from-absolute
     (+ (calendar-absolute-from-gregorian
         (list (nth 4 now) (nth 3 now) (nth 5 now)))
        (if offset offset 0)))))

-- 

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]