1 (** Wrapper around Perl [Date::Parse] class.
3 * Copyright (C) 2003 Merjis Ltd.
5 * $Id: pl_Date_Parse.ml,v 1.1 2003-11-19 16:28:23 rich Exp $
10 let _ = eval "use Date::Parse qw()"
12 (* XXX languages not supported yet - when it is supported, it'll be in
13 * [pl_Date_Language] anyway, not here -- RWMJ
16 let str2time ?zone date =
21 | Some zone -> [sv_of_string zone] in
22 let sv = call ~fn:"Date::Parse::str2time" args in
23 if sv_is_undef sv then
24 invalid_arg "Date::Parse: Could not parse date";
27 let strptime ?zone date =
32 | Some zone -> [sv_of_string zone] in
33 let svs = call_array ~fn:"Date::Parse::strptime" args in
35 [] -> invalid_arg "Date::Parse: Could not parse date"
36 | [ ss; mm; hh; day; month; year; zone ] ->
37 ((if sv_is_undef ss then None else Some (int_of_sv ss)),
38 (if sv_is_undef mm then None else Some (int_of_sv mm)),
39 (if sv_is_undef hh then None else Some (int_of_sv hh)),
40 (if sv_is_undef day then None else Some (int_of_sv day)),
41 (if sv_is_undef month then None else Some (int_of_sv month)),
42 (if sv_is_undef year then None else Some (int_of_sv year)),
43 (if sv_is_undef zone then None else Some (string_of_sv zone)))
45 failwith "Pl_Date_Parse: invalid list returned by strptime"