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: Mirko
Subject: Re: how to get calendar- for an offset day
Date: Mon, 22 Dec 2008 20:24:34 -0800 (PST)
User-agent: G2/1.0

On Dec 18, 10:49 am, reing...@emr.cs.iit.edu (Edward M. Reingold)
wrote:
> >>>>> "M" == Mirko  <mvuko...@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: reing...@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.

Thanks.  I'll give it a shot.

Mirko


reply via email to

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