From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Timothy Hobbs <tim.thelion@gmail.com>
Cc: EMACS list <help-gnu-emacs@gnu.org>
Subject: Re: Date manangement.
Date: Tue, 25 Mar 2008 12:18:35 +0100 [thread overview]
Message-ID: <87k5jr127o.fsf@thievol.homelinux.org> (raw)
In-Reply-To: <m3lk473jc5.fsf@xo-10-E6-7E.localdomain> (Timothy Hobbs's message of "Mon, 24 Mar 2008 14:25:46 -0700")
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
next prev parent reply other threads:[~2008-03-25 11:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-24 21:25 Date manangement Timothy Hobbs
2008-03-25 11:18 ` Thierry Volpiatto [this message]
2008-03-25 12:20 ` Dmitri Minaev
[not found] <mailman.9395.1206412275.18990.help-gnu-emacs@gnu.org>
2008-03-25 13:00 ` Giles Chamberlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k5jr127o.fsf@thievol.homelinux.org \
--to=thierry.volpiatto@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tim.thelion@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).