[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Date manangement.
From: |
Thierry Volpiatto |
Subject: |
Re: Date manangement. |
Date: |
Tue, 25 Mar 2008 12:18:35 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Timothy Hobbs <tim.thelion@gmail.com> writes:
> Hello. This is Timothy.
>
> Is there a good way to add on day to a date of any sort? time-date.el doesn't
> seem to be good at this. What I need to do is add a day, incramenting months,
> and years, correctly, so 2008/03/31+1 = 2008/04/00 not 2008/03/32...
>
> I am currently working on a bit of elisp for planner which imports ical files.
> So I need to be able to import events that span multiple days, as mutliple
> tasks.
> This requires walking through the days creating a task for each one covered.
>
> Timothy
>
>
>
Hello, may be we meet us on planner mailing-list, i sent you there
some code doing what you want, there is a function incrementing date,
you can easily modify it for your need. here is the function:
,----
| (defun tv-time-date-in-n-days (days)
| "Return the date in string form in n +/-days"
| (let* ((days-in-sec (* 3600 (* (+ days) 24)))
| (interval-days-sec (if `(< ,days 0)
| (+ (float-time (current-time)) days-in-sec)
| (- (float-time (current-time)) days-in-sec)))
| (sec-to-time (seconds-to-time interval-days-sec))
| (time-dec (decode-time sec-to-time))
| (new-date ""))
| (setq new-date (concat
| (int-to-string (nth 5 time-dec))
| "."
| (substring (int-to-string (/ (float (nth 4 time-dec)) 100))
2)
| "."
| (substring (int-to-string (/ (float (nth 3 time-dec)) 100))
2)))
| new-date))
`----
,----
| ELISP> (tv-time-date-in-n-days -12)
| "2008.03.13"
| ELISP> (tv-time-date-in-n-days 32)
| "2008.04.26"
`----
--
A + Thierry
Pub key: http://pgp.mit.edu