caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Xavier Leroy <xavier.leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] date manipulation library
Date: Mon, 15 Sep 2003 11:40:00 -0400	[thread overview]
Message-ID: <20030915154000.GN2354@alan-schm1p> (raw)
In-Reply-To: <20030915172135.A16340@pauillac.inria.fr>

* 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


  reply	other threads:[~2003-09-15 15:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-15 14:37 Alan Schmitt
2003-09-15 14:48 ` Antoine Schweitzer-Chaput
2003-09-15 15:21 ` Xavier Leroy
2003-09-15 15:40   ` Alan Schmitt [this message]
2003-09-15 16:38   ` David Brown
2003-09-15 15:22 ` Julien Signoles
2003-09-15 18:34   ` Stefano Zacchiroli
2003-09-15 18:45     ` Maxence Guesdon
2003-09-15 23:27     ` Julien Signoles
2003-09-16  7:20       ` Stefano Zacchiroli
2003-09-16  7:32         ` Mattias Waldau
2003-09-16  8:29           ` Benjamin Geer
2003-09-16 18:21             ` [Caml-list] Will Emacs camldebug-mode need an update for 3.07? Mattias Waldau
2003-09-15 15:25 ` [Caml-list] date manipulation library Matthieu Sozeau
2003-09-17  7:57 ` Pierre Weis
2003-09-17  8:24   ` Mattias Waldau
2003-09-17 15:17     ` Pierre Weis
2003-09-19 14:48       ` [Caml-list] A plea for clear licenses (Was: date manipulation library) Florian Hars
2003-09-20 14:22         ` [Caml-list] " Pierre Weis
2003-09-20 18:42         ` [Caml-list] " skaller
2003-09-21 16:33           ` Richard Jones
2003-09-23  6:28           ` [Caml-list] A plea for clear licenses Florian Hars
2003-09-23 23:17             ` Rafael 'Dido' Sevilla
2003-09-23 23:29               ` Michael Beach
2003-09-17  9:19   ` [Caml-list] date manipulation library Stefano Zacchiroli
2003-09-17 15:28     ` Pierre Weis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030915154000.GN2354@alan-schm1p \
    --to=alan.schmitt@polytechnique.org \
    --cc=caml-list@inria.fr \
    --cc=xavier.leroy@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).