Added .gitignore file for git.
[perl4caml.git] / examples / parsedate.ml
1 (* Example program which uses Date::Parse.
2  * Copyright (C) 2003 Merjis Ltd.
3  * $Id: parsedate.ml,v 1.2 2003-12-11 17:41:52 rich Exp $
4  *)
5
6 open Printf
7
8 open Pl_Date_Parse
9 open Pl_Date_Format
10
11 let () =
12   (* Parse dates passed on the command line. *)
13   if Array.length Sys.argv <= 1 then
14     eprintf "parsedate [list of quoted date strings ...]\n"
15   else (
16     let strings = List.tl (Array.to_list Sys.argv) in
17     List.iter (fun s ->
18                  printf "input string = '%s' ->\n" s;
19                  let t = str2time s in
20                  printf "\ttime_t = %f\n" t;
21                  let s = ctime t in
22                  printf "\tconverted back to string = %s\n" s;
23                  printf "\n"
24               ) strings
25   );
26
27   (* Perform a full collection - good way to find GC/allocation bugs. *)
28   Gc.full_major ()