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 RAA17628; Mon, 15 Sep 2003 17:21:37 +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 RAA19139 for ; Mon, 15 Sep 2003 17:21:36 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8FFLZf01590; Mon, 15 Sep 2003 17:21:35 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA18824; Mon, 15 Sep 2003 17:21:35 +0200 (MET DST) Date: Mon, 15 Sep 2003 17:21:35 +0200 From: Xavier Leroy To: caml-list@inria.fr, alan.schmitt@polytechnique.org Subject: Re: [Caml-list] date manipulation library Message-ID: <20030915172135.A16340@pauillac.inria.fr> References: <20030915143708.GK2354@alan-schm1p> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20030915143708.GK2354@alan-schm1p>; from alan.schmitt@polytechnique.org on Mon, Sep 15, 2003 at 10:37:08AM -0400 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sept:99 2004:99 normalized:01 increment:01 discard:02 precisely:02 unix:02 unix:02 oct:03 library:03 library:03 01.:96 equivalent:05 function:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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. - Xavier Leroy ------------------- 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