all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Date manangement.
@ 2008-03-24 21:25 Timothy Hobbs
  2008-03-25 11:18 ` Thierry Volpiatto
  2008-03-25 12:20 ` Dmitri Minaev
  0 siblings, 2 replies; 4+ messages in thread
From: Timothy Hobbs @ 2008-03-24 21:25 UTC (permalink / raw)
  To: EMACS list

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Date manangement.
  2008-03-24 21:25 Date manangement Timothy Hobbs
@ 2008-03-25 11:18 ` Thierry Volpiatto
  2008-03-25 12:20 ` Dmitri Minaev
  1 sibling, 0 replies; 4+ messages in thread
From: Thierry Volpiatto @ 2008-03-25 11:18 UTC (permalink / raw)
  To: Timothy Hobbs; +Cc: EMACS list

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Date manangement.
  2008-03-24 21:25 Date manangement Timothy Hobbs
  2008-03-25 11:18 ` Thierry Volpiatto
@ 2008-03-25 12:20 ` Dmitri Minaev
  1 sibling, 0 replies; 4+ messages in thread
From: Dmitri Minaev @ 2008-03-25 12:20 UTC (permalink / raw)
  To: Timothy Hobbs; +Cc: EMACS list

On Tue, Mar 25, 2008 at 1:25 AM, Timothy Hobbs <tim.thelion@gmail.com> wrote:
>  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...

Use Calc, either as a separate application (M-x calc), or in embedded
mode (see more in  `info calc`, or from your own lisp code:

(calc-eval "<21 jan 2008> +110")
"<Sat May 10, 2008>"


-- 
With best regards,
Dmitri Minaev

Russian history blog: http://minaev.blogspot.com




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Date manangement.
       [not found] <mailman.9395.1206412275.18990.help-gnu-emacs@gnu.org>
@ 2008-03-25 13:00 ` Giles Chamberlin
  0 siblings, 0 replies; 4+ messages in thread
From: Giles Chamberlin @ 2008-03-25 13:00 UTC (permalink / raw)
  To: help-gnu-emacs

Timothy Hobbs <tim.thelion@gmail.com> writes:

>
> 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...

Have a look at calendar-absolute-from-gregorian which returns an
integer rep of the date which you can then do arithmetic with.
-- 
Giles


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-25 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-24 21:25 Date manangement Timothy Hobbs
2008-03-25 11:18 ` Thierry Volpiatto
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.