From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA15814; Mon, 15 Sep 2003 17:40:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA18804 for ; Mon, 15 Sep 2003 17:40:12 +0200 (MET DST) Received: from jamlikhet.polytechnique.org (b.mx.polytechnique.org [129.104.30.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8FFeBf03385; Mon, 15 Sep 2003 17:40:12 +0200 (MET DST) Received: from alan-schm1p.inria.fr (DHCP12-8.CIS.UPENN.EDU [158.130.13.28]) by ssl.polytechnique.org (Postfix) with ESMTP id A86E4B6A6; Mon, 15 Sep 2003 17:40:10 +0200 (CEST) Received: by alan-schm1p.inria.fr (Postfix, from userid 501) id F007241F3; Mon, 15 Sep 2003 11:40:00 -0400 (EDT) Date: Mon, 15 Sep 2003 11:40:00 -0400 From: Alan Schmitt To: Xavier Leroy Cc: caml-list@inria.fr Subject: Re: [Caml-list] date manipulation library Message-ID: <20030915154000.GN2354@alan-schm1p> Mail-Followup-To: Xavier Leroy , caml-list@inria.fr References: <20030915143708.GK2354@alan-schm1p> <20030915172135.A16340@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030915172135.A16340@pauillac.inria.fr> X-Editor: Vim http://vim.sf.net/ X-Info: http://pauillac.inria.fr/~aschmitt/ X-Operating-System: Linux/2.4.21-6mdk (i686) X-Uptime: 11:32:32 up 1 day, 4:25, 8 users, load average: 0.00, 0.06, 0.07 User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sept:99 2004:99 normalized:01 troubling:01 increment:01 discard:02 precisely:02 unix:02 unix:02 wrote:03 oct:03 library:03 library:03 01.:96 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk * Xavier Leroy (xavier.leroy@inria.fr) wrote: > > I am writing an application that needs to manipulate dates. More > > precisely, it needs a function that, given a date and a duration (12 > > days, 2 weeks, 3 months ...) returns the date at the end of the > > duration. Is there a library providing such a thing ? > > Good old Unix.mktime could perhaps do the job. It has the ability to > correct for impossible dates, e.g. change Sept 32nd into Oct 2nd, > or 2003-13-01 into 2004-01-01. > > So, perhaps you could just increment the tm_mday, tm_mon or tm_year of > a "tm" record by the specified amount, then call Unix.mktime and > discard the first result to get a normalized, but equivalent date. Wow, this is great. Now I can answer the question that as been troubling me for some time: "What is the date one year after Feb 29th, 2000" ;-) Thanks, Alan Schmitt -- The hacker: someone who figured things out and made something cool happen. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners