Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] date manipulation library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] date manipulation library
> 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