diff --git a/src/oDate.ml b/src/oDate.ml index ef86a5c..6f9ada4 100644 --- a/src/oDate.ml +++ b/src/oDate.ml @@ -383,11 +383,10 @@ module Make(Implem : Implem) = struct length = String.length str } - (* - let parse_constant s = + let _parse_constant s = let size = String.length s in (fun ptr -> - let {str;pos; _} = ptr in + let {str;pos;_} = ptr in let rec loop i = if i = size then () @@ -398,7 +397,6 @@ module Make(Implem : Implem) = struct let () = loop 0 in ptr.pos <- ptr.pos + size ) - *) let parse_constant_i s = let (+++) a i = char_of_int ( int_of_char a + i) in @@ -476,22 +474,20 @@ module Make(Implem : Implem) = struct end) let parse_single_char = parse_char ~min:1 ~max:1 - (* let parse_char_plus x = parse_char ~min:1 x *) - + let _parse_char_plus x = parse_char ~min:1 x + let ignore' f = (fun ptr -> ignore (f ptr)) let (>>==) f g = (fun ptr -> g (f ptr)) let (>>=|) f c = - (fun ptr -> ignore (f ptr); c) + (fun ptr -> f ptr; c) - (* -let parse_remaining ptr = + let _parse_remaining ptr = let size = String.length ptr.str in let s = String.sub ptr.str ptr.pos (size - ptr.pos) in ptr.pos <- size; s - *) - + let parse_option p ptr= try Some (p ptr) with _ -> None @@ -504,7 +500,7 @@ let parse_remaining ptr = let s = Weekday.to_string w in let s = if short then String.sub s 0 3 else s in loop (succ i) ((parse_constant_i s >>=| w) :: acc) in - parse_sum (loop 0 [(fun _ -> failwith "weekday")]) + parse_sum (loop 0 [(fun _ptr -> failwith "weekday")]) let parse_month short = let rec loop i acc = @@ -517,26 +513,22 @@ let parse_remaining ptr = loop (succ i) ((parse_constant_i s >>=| m) :: acc) in parse_sum (loop 1 []) - (* - let parse_seq l ptr = + let _parse_seq l ptr = let rec loop acc = function | [] -> List.rev acc | x::xs -> loop (x ptr :: acc) xs in loop [] l - *) - - (* - let parse_fold f acc l ptr = + + let _parse_fold f acc l ptr = let rec loop acc = function | [] -> acc | x::xs -> loop (f acc (x ptr)) xs in loop acc l - *) - + let parse_sign = parse_sum [ - parse_single_char '-' >>=| (-); - parse_single_char '+' >>=| (+) + (ignore' (parse_single_char '-') >>=| (-)); + (ignore' (parse_single_char '+') >>=| (+)) ] let parse_timezone = @@ -621,7 +613,7 @@ let parse_remaining ptr = let tokens = date_token s in let l = List.rev_map (function | String s -> parse_constant_i s >>=| (fun d -> d) - | Space -> parse_space >>=| (fun d -> d) + | Space -> ignore' parse_space >>=| (fun d -> d) | Directive (p,c) -> parse_directive (p,c) | EOL -> assert false) tokens in @@ -643,7 +635,7 @@ let parse_remaining ptr = ) abbreviations in List.iter add_abbr abbr - let human ?tz {s;m;h;day;month;year;tz=tz';_} = + let human ?tz {s;m;h;day;month;year;tz=tz';wday=_} = let tz = match tz with | None -> tz' | Some x -> x in @@ -776,7 +768,7 @@ let parse_remaining ptr = let a = a mod n in if a < 0 then a + n else a - let calendar_advance t {D.forward;h;m;s;day;month;year;_} = + let calendar_advance t {D.forward;h;m;s;day;month;year;ms=_} = let human = To.human t in let add = if forward then (fun a x -> a + x) else (fun a x -> a - x) in let human = {human with @@ -987,7 +979,7 @@ module MakeImplem(C : Clock) : Implem = struct } let now () = C.time () let now_milliseconds () = C.gettimeofday () *. 1000. - let from_human ?tz {s;m;h;day;month;year;tz=tz';_} = + let from_human ?tz {s;m;h;day;month;year;tz=tz';wday=_} = let tz = match tz with | None -> tz' | Some tz -> tz in diff --git a/src/oDuration.ml b/src/oDuration.ml index f9511b9..aafbe8d 100644 --- a/src/oDuration.ml +++ b/src/oDuration.ml @@ -37,6 +37,7 @@ module type S = sig val human : human_readable -> t end module To : sig + val ms : t -> int val s : t -> int val s_float : t -> float val m : t -> int @@ -90,7 +91,7 @@ module D : S = struct end module To = struct - (* let ms t = int_of_float (O.to_float t) *) + let ms t = int_of_float (O.to_float t) let s_float t = O.(to_float (t / ms_in_s)) let aux divide t = int_of_float (O.to_float t /. O.to_float divide) let s = aux ms_in_s diff --git a/src/oDuration.mli b/src/oDuration.mli index 2548a87..c9fa6b0 100644 --- a/src/oDuration.mli +++ b/src/oDuration.mli @@ -40,6 +40,7 @@ module type S = sig val human : human_readable -> t end module To : sig + val ms : t -> int val s : t -> int val s_float : t -> float val m : t -> int