From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: Date manangement. Date: Tue, 25 Mar 2008 12:18:35 +0100 Message-ID: <87k5jr127o.fsf@thievol.homelinux.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206443156 28429 80.91.229.12 (25 Mar 2008 11:05:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Mar 2008 11:05:56 +0000 (UTC) Cc: EMACS list To: Timothy Hobbs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 25 12:06:26 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Je6yh-0007i8-F5 for geh-help-gnu-emacs@m.gmane.org; Tue, 25 Mar 2008 12:06:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Je6y6-00023P-EY for geh-help-gnu-emacs@m.gmane.org; Tue, 25 Mar 2008 07:05:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Je6xS-0001nP-EA for help-gnu-emacs@gnu.org; Tue, 25 Mar 2008 07:04:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Je6xN-0001kH-Du for help-gnu-emacs@gnu.org; Tue, 25 Mar 2008 07:04:45 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Je6xM-0001k5-Ui for help-gnu-emacs@gnu.org; Tue, 25 Mar 2008 07:04:41 -0400 Original-Received: from fk-out-0910.google.com ([209.85.128.191]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Je6xL-000600-Uh for help-gnu-emacs@gnu.org; Tue, 25 Mar 2008 07:04:40 -0400 Original-Received: by fk-out-0910.google.com with SMTP id 26so3873866fkx.10 for ; Tue, 25 Mar 2008 04:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:cc:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=BhHofamfg0PqEe50dlkPCgrV0EOmLldXul7euCHGbhA=; b=YfBRQXPwgEf7LS1GWYqVepKjrUaKx8hqVSeOSnCl3dpu5wdJ61y3P8HQgtoBTfY/yJB9E8qRLmIZisFd23yQtwwMwzZh1wnZoz/nJKclRcmWetr9GnWRCz+eBCMiEfd551jifFSNPuh/Y9SS5OfdGomfCTTHmdE2QH5yW1UnSVg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=from:to:cc:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=aaaunwdedE6/1wSFGjfzzGsXaCGuaGvmRqOyMoBsuSaZZ9SCFjD1tlmiJT9j7wZG22HMWpO1W8S+Ohf5ufx1GpGlcGSiYbfR6hG0FHgO2ye/GEJZ2cFn5QT9ygSiirqV/SRg2Id7YlEXzTrrMBoiZylGn25rQMI9ayJoeLnJ4l8= Original-Received: by 10.82.116.15 with SMTP id o15mr20504964buc.11.1206443075782; Tue, 25 Mar 2008 04:04:35 -0700 (PDT) Original-Received: from thievol.homelinux.org ( [77.197.77.2]) by mx.google.com with ESMTPS id l12sm8046411fgb.8.2008.03.25.04.04.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Mar 2008 04:04:34 -0700 (PDT) In-Reply-To: (Timothy Hobbs's message of "Mon, 24 Mar 2008 14:25:46 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52682 Archived-At: Timothy Hobbs 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