1 (** Wrapper around Perl [Date::Calc] class.
3 * Copyright (C) 2003 Merjis Ltd.
5 * $Id: pl_Date_Calc.ml,v 1.1 2003-11-19 16:28:23 rich Exp $
10 let _ = eval "use Date::Calc qw()"
12 let days_in_year year month =
13 int_of_sv (call ~fn:"Date::Calc::Days_in_Year"
14 [sv_of_int year; sv_of_int month])
16 let days_in_month year month =
17 int_of_sv (call ~fn:"Date::Calc::Days_in_Month"
18 [sv_of_int year; sv_of_int month])
20 let weeks_in_year year =
21 int_of_sv (call ~fn:"Date::Calc::Weeks_in_Year" [sv_of_int year])
24 bool_of_sv (call ~fn:"Date::Calc::leap_year" [sv_of_int year])
26 let check_date year month day =
27 bool_of_sv (call ~fn:"Date::Calc::check_date"
28 [sv_of_int year; sv_of_int month; sv_of_int day])
30 let check_time hour min sec =
31 bool_of_sv (call ~fn:"Date::Calc::check_time"
32 [sv_of_int hour; sv_of_int min; sv_of_int sec])
34 let check_business_date year week dow =
35 bool_of_sv (call ~fn:"Date::Calc::check_business_date"
36 [sv_of_int year; sv_of_int week; sv_of_int dow])
38 let day_of_year year month day =
39 int_of_sv (call ~fn:"Date::Calc::Day_of_Year"
40 [sv_of_int year; sv_of_int month; sv_of_int day])
42 let date_to_days year month day =
43 int_of_sv (call ~fn:"Date::Calc::Date_to_Days"
44 [sv_of_int year; sv_of_int month; sv_of_int day])
46 let day_of_week year month day =
47 int_of_sv (call ~fn:"Date::Calc::Day_of_Week"
48 [sv_of_int year; sv_of_int month; sv_of_int day])
50 let week_number year month day =
51 int_of_sv (call ~fn:"Date::Calc::Week_Number"
52 [sv_of_int year; sv_of_int month; sv_of_int day])
54 let week_of_year year month day =
55 let r = call_array ~fn:"Date::Calc::Week_of_Year"
56 [sv_of_int year; sv_of_int month; sv_of_int day] in
58 [week; year] -> int_of_sv week, int_of_sv year
59 | _ -> failwith "Pl_Date_Calc: week_of_year: unexpected return value"
61 let monday_of_week week year =
62 let r = call_array ~fn:"Date::Calc::Monday_of_Week"
63 [sv_of_int week; sv_of_int year] in
65 [year; month; day] -> int_of_sv year, int_of_sv month, int_of_sv day
66 | _ -> failwith "Pl_Date_Calc: monday_of_week: unexpected return value"
68 (* at this point I got bored ... - RWMJ *)