OCaml using Calendar
From the toplevel
# #use "topfind";; # #require "calendar";; /usr/lib/ocaml/unix.cma: loaded /usr/lib/ocaml/str.cma: loaded /usr/lib/ocaml/calendar: added to search path /usr/lib/ocaml/calendar/calendarLib.cma: loaded
Note that the library is "Calendar", but "calendarLib.cma" is loaded. So, to set a Date from a String:
# let d = CalendarLib.Printer.Precise_Fcalendar.from_fstring "%F %T" "2011-08-16 16:00:01";; val d : CalendarLib.Printer.Precise_Fcalendar.t =Or to print a Date to a String:
# CalendarLib.Printer.Precise_Fcalendar.to_string d;; - : string = "2011-08-16 16:00:01" # CalendarLib.Printer.Precise_Fcalendar.sprint "%Y-%m-%d %H" d;; - : string = "2011-08-16 16" # CalendarLib.Printer.Precise_Fcalendar.sprint "%Y-%m-%d %H:%M:%S" d;; - : string = "2011-08-16 16:00:01"