More robust implementation of duration multiplication

This commit is contained in:
Denis Merigoux 2022-06-01 15:15:22 +02:00
parent 0e68c07567
commit 6e4e646dd8
No known key found for this signature in database
GPG Key ID: EE99DCFA365C3EE3

View File

@ -292,8 +292,11 @@ let ( /^ ) (d1 : duration) (d2 : duration) : decimal =
with CalendarLib.Date.Period.Not_computable -> raise IndivisableDurations with CalendarLib.Date.Period.Not_computable -> raise IndivisableDurations
let ( *^ ) (d1 : duration) (i1 : integer) : duration = let ( *^ ) (d1 : duration) (i1 : integer) : duration =
let nb_day = CalendarLib.Date.Period.nb_days d1 in let y, m, d = CalendarLib.Date.Period.ymd d1 in
CalendarLib.Date.Period.make 0 0 (nb_day * integer_to_int i1) CalendarLib.Date.Period.make
(y * integer_to_int i1)
(m * integer_to_int i1)
(d * integer_to_int i1)
let ( <=$ ) (m1 : money) (m2 : money) : bool = Z.compare m1 m2 <= 0 let ( <=$ ) (m1 : money) (m2 : money) : bool = Z.compare m1 m2 <= 0
let ( >=$ ) (m1 : money) (m2 : money) : bool = Z.compare m1 m2 >= 0 let ( >=$ ) (m1 : money) (m2 : money) : bool = Z.compare m1 m2 >= 0