Skip to content

Commit

Permalink
Merge pull request #669 from ocsigen/wasm
Browse files Browse the repository at this point in the history
Wasm support
  • Loading branch information
balat authored Sep 28, 2024
2 parents e776db2 + b2650e1 commit 10f3812
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ depends: [
"yojson" {>= "1.6.0"}
"resource-pooling" {>= "1.0" & < "2.0"}
"cohttp-lwt-unix"
"js_of_ocaml" {>= "5.5.0"}
"re" {>= "1.7.2"}
]
depexts: [
Expand Down
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 10f3812

Please sign in to comment.