I'm generating some logs for unit tests, and I would like the preamble
to a particular unit test's log file to read: '/foo/bar test ran 20
Jan 2007 at 21:41" or something similar.
I could write this module, but I figure there's *got* to be something
out there better than I would make in the time I have.
Thanks in advance.
-Denis
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
I noticed Calendar [1] on the Hump a while ago... it looks pretty
useful. The API includes a pretty printer.
[1] http://www.lri.fr/~signoles/prog.en.html
- Chris
(*
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 <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
I would strongly advise you tu use fixed-length fields with leading zeros:
the big advantage of using the year-month-day order, instead of
month-day-year or day-month-year, is that the lexical order of the string is
the same as the chronological order of the date. Using variable-length
fields breaks this. Furthermore, it makes it harder to parse the timestamp.
On the other hand, it is important not to forget "UTC".
While I am at it, I believe that yyyy-mm-dd is a more common format as
yyyy/mm/dd.
> //Timestamp: 2007/1/13 5:36:37 (local)
It is a shame that whoever designed the tm structure in the first place
forgot the tm_gmtoff field.
Regards,
--
Nicolas George
Indeed... it is called ISO 8601. :)
Robert Roessler
roes...@rftp.com
http://www.rftp.com