[Top][All Lists]

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

Re: how do you compute date difference in emacs?

From: Jason Rumney
Subject: Re: how do you compute date difference in emacs?
Date: Tue, 04 May 2010 15:44:55 -0000
User-agent: G2/1.0

On Apr 17, 8:39 am, Xah Lee <address@hidden> wrote:

> here's some complaints about the emacs solutions in case some emacs
> dev is interested.
> The calender mode... so i type Alt+x calendar. Been using it for 10
> years, but mostly only just to look at today's date and day of the
> week.
> After Edward's suggestion, i thought yeah why didn't i thought of it,
> cause i knew the emacs calender does all sort of esoteric calender
> systems and thus must contain ways to do simple day substraction.  But
> while in calender, am not sure how to use it to computer yyyy-mm-dd
> minus days.

In calendar mode, you can do it interactively.

>From the "Goto" menu, you can find "Other date" which has the keyboard
shortcut "g d" (in your example case you don't need this step, since
the date was yesterdays date). Then you can use C-u NUMBER_OF_DAYS
<left> to go back a number of days.

> For Jose Romero's suggestion:
> (format-time-string
>  "%Y-%m-%d"
>  (time-subtract (date-to-time "2010-04-16 00:00") (days-to-time 215)))
> this code results in "1999-05-30".

In 23.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.3) of 2010-03-16 on
crested, modified by Debian; the code above results in an error,
because the seconds are required in the argument to date-to-time.

reply via email to

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