Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm support #669

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading