Skip to content

Add Intl.RelativeTimeFormat #2070

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

toastal
Copy link
Contributor

@toastal toastal commented Jul 4, 2025

https://tc39.es/ecma402/#relativetimeformat-objects

NOTE: I do not understand how these comment tests work

1

Footnotes

  1. Please consider giving up MS GitHub or offering a non-proprietary, non-US-corporate-controlled mirror for this free software project. I wish to delete this Microsoft account in the future, but I need more projects like this to support alternative methods to send patches & contribute.

@toastal toastal force-pushed the relative-time-format branch 4 times, most recently from 510eddf to 56e6a6e Compare July 4, 2025 14:05
@hhugo hhugo force-pushed the relative-time-format branch 2 times, most recently from c72fcbf to f21142a Compare July 9, 2025 18:20
@toastal toastal force-pushed the relative-time-format branch from f21142a to 36dc208 Compare July 24, 2025 11:59
@toastal toastal requested a review from hhugo July 24, 2025 12:00

class type t = object
method format :
(Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.readonly_prop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a readonly_prop and not a method ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ rg "method format\s" -A 1 lib/js_of_ocaml/intl.ml
234:    method format : (Js.date Js.t -> Js.js_string Js.t) Js.readonly_prop
235-
--
366:    method format : (Js.number Js.t -> Js.js_string Js.t) Js.readonly_prop
367-
--
457:    method format :
458-      (Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.readonly_prop

Why are all other formats readonly_prop?

let () = options##.numeric := "auto" in
let () = options##.style := "short" in
let th_rtf = new%js Intl.relativeTimeFormat_constr (def (jas [| "th-TH" |])) options in
fc (th_rtf.format -1 "day");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> (new Intl.RelativeTimeFormat("th-TH", { numeric: "auto", style: "short" })).format(-1, "day")
"เมื่อวาน" 

Excepted output for the given language in the browser console.

“This is not correct” isn’t a helpful comment for review. I think I need the ## but I don’t know what that operator is doing. I believe # is used for OCaml objects (which are almost never talked about) so I would guess this ## is something similar but specific to js_of_ocaml? I am just trying to match the patterns I see in surrounding code to get access to the missing Intl.RelativeTimeFormat.

@toastal toastal force-pushed the relative-time-format branch 4 times, most recently from 0b786f0 to c8960b2 Compare July 30, 2025 03:50
@toastal toastal requested a review from hhugo July 30, 2025 03:57
toastal added 3 commits July 30, 2025 12:10
Not entirely sure what these are or how they work
@toastal toastal force-pushed the relative-time-format branch from c8960b2 to 016d15b Compare July 30, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants