From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id C181CBC0B for ; Sun, 21 Jan 2007 09:43:58 +0100 (CET) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0L8huT7018367 for ; Sun, 21 Jan 2007 09:43:57 +0100 Received: from ppp27-234.lns1.syd6.internode.on.net (HELO rosella) ([59.167.27.234]) by ipmail01.adl2.internode.on.net with ESMTP; 21 Jan 2007 19:13:54 +1030 X-IronPort-AV: i="4.13,217,1167571800"; d="scan'208"; a="76610418:sNHT30225412" Subject: Re: [Caml-list] Time stamp module floating around? From: skaller To: Denis Bueno Cc: OCaml Mailing List In-Reply-To: <6dbd4d000701201842h5130b540x97648a3d2d058e6e@mail.gmail.com> References: <6dbd4d000701201842h5130b540x97648a3d2d058e6e@mail.gmail.com> Content-Type: text/plain Date: Sun, 21 Jan 2007 19:43:49 +1100 Message-Id: <1169369029.6178.2.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45B327CC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; utime:01 gmtime:01 localtime:01 scrap:98 1900:98 sourceforge:01 unix:01 unix:01 wrote:01 compile:01 compile:01 caml-list:01 string:02 string:02 module:03 On Sat, 2007-01-20 at 21:42 -0500, Denis Bueno wrote: > I'm looking for simple bit of code that will print human-readable > timestamps. Something suitable for a log file. (* Scrap used in Felix for lines like: //Timestamp: 2007/1/12 18:36:37 UTC //Timestamp: 2007/1/13 5:36:37 (local) *) let tim() = let now = (Unix.times()).Unix.tms_utime in let elapsed = now -. !last_time in last_time := now; elapsed ;; let format_time tm = si (tm.Unix.tm_year + 1900) ^ "/" ^ si (tm.Unix.tm_mon + 1) ^ "/" ^ si tm.Unix.tm_mday ^ " " ^ si tm.Unix.tm_hour ^ ":" ^ si tm.Unix.tm_min ^ ":" ^ si tm.Unix.tm_sec ;; try (* Time initialisation *) let compile_start = Unix.time () in let compile_start_gm = Unix.gmtime compile_start in let compile_start_local = Unix.localtime compile_start in let compile_start_gm_string = format_time compile_start_gm ^ " UTC" in let compile_start_local_string = format_time compile_start_local ^ " (local)" in -- John Skaller Felix, successor to C++: http://felix.sf.net