Updated deps
[perl4caml.git] / wrappers / pl_Date_Format.ml
1 (** Wrapper around Perl [Date::Format] class.
2   *
3   * Copyright (C) 2003 Merjis Ltd.
4   *
5   * $Id: pl_Date_Format.ml,v 1.1 2003-11-19 16:28:23 rich Exp $
6   *)
7
8 open Perl
9
10 let _ = eval "use Date::Format qw()"
11
12 let language lang =
13   call_class_method_void "Date::Format" "language" [sv_of_string lang]
14
15 (* This is just provided for your convenience so you can pass the resulting
16  * list of SVs directly to the second argument of {!Pl_Date_Format.strftime}.
17  *)
18 let localtime () =
19   call_array ~fn:"localtime" []
20
21 let time2str ?zone templ time =
22   let args =
23     [sv_of_string templ; sv_of_float time] @
24     match zone with
25         None -> []
26       | Some zone -> [sv_of_string zone] in
27   string_of_sv (call ~fn:"Date::Format::time2str" args)
28
29 let strftime ?zone templ time =
30   let args =
31     (sv_of_string templ :: time) @
32     match zone with
33         None -> []
34       | Some zone -> [sv_of_string zone] in
35   string_of_sv (call ~fn:"Date::Format::strftime" args)
36
37 let ctime ?zone time =
38   let args =
39     [sv_of_float time] @
40     match zone with
41         None -> []
42       | Some zone -> [sv_of_string zone] in
43   string_of_sv (call ~fn:"Date::Format::ctime" args)
44
45 let asctime ?zone time =
46   let args =
47     [sv_of_float time] @
48     match zone with
49         None -> []
50       | Some zone -> [sv_of_string zone] in
51   string_of_sv (call ~fn:"Date::Format::asctime" args)