Skip to content

Commit

Permalink
Explicit float conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Sep 14, 2023
1 parent 8d862c0 commit 826780e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/client/eliommod_cookies.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let set_table ?(in_local_storage = false) host t =

let now () =
let date = new%js Js.date_now in
date##getTime /. 1000.
Js.to_float date##getTime /. 1000.

(** [in_local_storage] implements cookie substitutes for iOS WKWebView *)
let update_cookie_table ?(in_local_storage = false) host cookies =
Expand Down
2 changes: 1 addition & 1 deletion src/lib/client/eliommod_dom.ml
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,4 @@ let onhashchange f =
f Dom_html.window##.location##.hash)
in
ignore
Dom_html.window ## (setInterval (Js.wrap_callback check) (0.2 *. 1000.))
Dom_html.window ## (setInterval (Js.wrap_callback check) (Js.float (0.2 *. 1000.)))
2 changes: 1 addition & 1 deletion src/lib/eliom_client.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ let random_int =
Js.Unsafe.global ##. crypto
## (getRandomValues (new%js Typed_array.int32Array 1))
0
else fun () -> truncate (4294967296. *. Js.math##random)
else fun () -> truncate (4294967296. *. Js.to_float Js.math##random)

let section_page = Lwt_log.Section.make "eliom:client:page"

Expand Down
8 changes: 4 additions & 4 deletions src/lib/eliom_comet.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module Configuration = struct
then
match (get ()).time_between_request_unfocused, focused () with
| Some ((a, b, c) :: l), Some start ->
let now = (new%js Js.date_now)##getTime in
let now = Js.to_float (new%js Js.date_now)##getTime in
(* time from idle start *)
let t =
max 0. (((now -. start) *. 0.001) -. (get ()).time_after_unfocus)
Expand Down Expand Up @@ -307,7 +307,7 @@ end = struct
in
let suspend_activity () =
if handler.hd_activity.focused = None
then handler.hd_activity.focused <- Some (new%js Js.date_now)##getTime
then handler.hd_activity.focused <- Some (Js.to_float (new%js Js.date_now)##getTime)
in
let visibility_change_callback () =
if document_hidden () then suspend_activity () else resume_activity ()
Expand All @@ -324,7 +324,7 @@ end = struct
if tbru = Some [0., 0., 0.] (* Always active *)
then `Active
else
let now = (new%js Js.date_now)##getTime in
let now = Js.to_float (new%js Js.date_now)##getTime in
if now -. t
< (Configuration.get ()).Configuration.time_after_unfocus *. 1000.
then `Active
Expand All @@ -340,7 +340,7 @@ end = struct
then
hd.hd_activity.focused <-
Some
((new%js Js.date_now)##getTime
(Js.to_float (new%js Js.date_now)##getTime
-. ((Configuration.get ()).Configuration.time_after_unfocus *. 1000.)
))
else hd.hd_activity.focused <- None;
Expand Down

0 comments on commit 826780e

Please sign in to comment.