Skip to content

Add Intl.RelativeTimeFormat#2070

Open
toastal wants to merge 3 commits intoocsigen:masterfrom
toastal:relative-time-format
Open

Add Intl.RelativeTimeFormat#2070
toastal wants to merge 3 commits intoocsigen:masterfrom
toastal:relative-time-format

Conversation

@toastal
Copy link
Copy Markdown
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
Comment thread lib/js_of_ocaml/intl.mli Outdated
@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
Comment thread lib/js_of_ocaml/intl.mli Outdated

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
Copy Markdown
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
Copy Markdown
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?

Comment thread lib/js_of_ocaml/intl.mli Outdated
Comment thread lib/js_of_ocaml/intl.mli Outdated
Comment thread lib/js_of_ocaml/intl.mli Outdated
Comment thread lib/js_of_ocaml/intl.mli Outdated
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
Copy Markdown
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
Copy Markdown
Contributor Author

@toastal toastal Jul 30, 2025

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")
"เมื่อวาน" 

Expected 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 toastal force-pushed the relative-time-format branch from c8960b2 to 016d15b Compare July 30, 2025 05:11
@smorimoto smorimoto added the lib label Aug 25, 2025
@toastal toastal force-pushed the relative-time-format branch from 016d15b to 9cad447 Compare October 7, 2025 18:42
@toastal toastal force-pushed the relative-time-format branch from 9cad447 to 9ed2188 Compare December 1, 2025 10:12
@hhugo hhugo mentioned this pull request Jan 30, 2026
9 tasks
toastal added 3 commits April 29, 2026 07:44
Not entirely sure what these are or how they work
@hhugo hhugo force-pushed the relative-time-format branch from 9ed2188 to 5251d4b Compare April 29, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants