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 21, 2024
1 parent ac9a3d0 commit b2650e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/os_date.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,20 @@ let to_utc ?(timezone = user_tz ()) d =

let%client to_local d =
let d = CalendarLib.Calendar.to_unixfloat d in
let o = (new%js Js.date_fromTimeValue (d *. 1000.))##getTimezoneOffset in
let o =
(new%js Js.date_fromTimeValue (Js.float (d *. 1000.)))##getTimezoneOffset
in
CalendarLib.Calendar.from_unixfloat (d -. (float o *. 60.))

let%client to_utc d =
let d = CalendarLib.Calendar.to_unixfloat d in
let o = (new%js Js.date_fromTimeValue (d *. 1000.))##getTimezoneOffset in
let o =
(new%js Js.date_fromTimeValue (Js.float (d *. 1000.)))##getTimezoneOffset
in
let d' = d +. (float o *. 60.) in
let o' = (new%js Js.date_fromTimeValue (d' *. 1000.))##getTimezoneOffset in
let o' =
(new%js Js.date_fromTimeValue (Js.float (d' *. 1000.)))##getTimezoneOffset
in
CalendarLib.Calendar.from_unixfloat
(if o = o'
then d' (* We guessed the DST status right *)
Expand Down

0 comments on commit b2650e1

Please sign in to comment.