-
Notifications
You must be signed in to change notification settings - Fork 195
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -346,9 +346,16 @@ then ( | |||||||||
(intl##._PluralRules##supportedLocalesOf | ||||||||||
(jas [| "ban"; "id-u-co-pinyin"; "de-ID" |]) | ||||||||||
(def options)) | ||||||||||
let options = Intl.RelativeTimeFormat.options () in | ||||||||||
let () = options##.numeric := "auto" in | ||||||||||
let () = options##.style := "short" in | ||||||||||
Comment on lines
+351
to
+352
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
let th_rtf = new%js Intl.relativeTimeFormat_constr (def (jas [| "th-TH" |])) options in | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
fc (th_rtf.format -1 "day"); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not correct |
||||||||||
with Error err -> Console.console##debug (string (string_of_error err))) | ||||||||||
else Console.console##debug (string "Intl is not supported!") | ||||||||||
]} | ||||||||||
@see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl> for API documentation. | ||||||||||
@see <https://www.ecma-international.org/ecma-402/1.0/> for the ECMAScript specification. *) | ||||||||||
|
||||||||||
|
@@ -627,6 +634,48 @@ module PluralRules : sig | |||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
module RelativeTimeFormat : sig | ||||||||||
include Shared | ||||||||||
|
||||||||||
class type resolved_options = object | ||||||||||
method locale : Js.js_string Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method style : Js.js_string Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method numberingSystem : Js.js_string Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method numeric : Js.js_string Js.t Js.readonly_prop | ||||||||||
end | ||||||||||
|
||||||||||
class type options = object | ||||||||||
method localeMatcher : Js.js_string Js.t Js.prop | ||||||||||
|
||||||||||
method numberingSystem : Js.js_string Js.t Js.optdef Js.prop | ||||||||||
|
||||||||||
method style : Js.js_string Js.t Js.optdef Js.prop | ||||||||||
|
||||||||||
method numeric : Js.js_string Js.t Js.optdef Js.prop | ||||||||||
end | ||||||||||
|
||||||||||
val options : unit -> options Js.t | ||||||||||
|
||||||||||
class type format_part = object | ||||||||||
method _type : Js.js_string Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method _value : Js.js_string Js.t Js.readonly_prop | ||||||||||
end | ||||||||||
|
||||||||||
class type t = object | ||||||||||
method format : | ||||||||||
(Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.readonly_prop | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a readonly_prop and not a method ? |
||||||||||
|
||||||||||
method formatToParts : | ||||||||||
Js.date Js.t Js.optdef -> format_part Js.t Js.js_array Js.t Js.meth | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This signature is not correct. this method takes a number and a string |
||||||||||
|
||||||||||
method resolvedOptions : unit -> resolved_options Js.t Js.meth | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
class type intl = object | ||||||||||
method _Collator : Collator._object Js.t Js.readonly_prop | ||||||||||
|
||||||||||
|
@@ -636,6 +685,8 @@ class type intl = object | |||||||||
|
||||||||||
method _PluralRules : PluralRules._object Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method _RelativeTimeFormat : RelativeTimeFormat._object Js.t Js.readonly_prop | ||||||||||
|
||||||||||
method getCanonicalLocales : | ||||||||||
Js.js_string Js.t Js.js_array Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth | ||||||||||
end | ||||||||||
|
@@ -666,4 +717,10 @@ val pluralRules_constr : | |||||||||
-> PluralRules.t Js.t) | ||||||||||
Js.constr | ||||||||||
|
||||||||||
val relativeTimeFormat_constr : | ||||||||||
( Js.js_string Js.t Js.js_array Js.t Js.optdef | ||||||||||
-> RelativeTimeFormat.options Js.t Js.optdef | ||||||||||
-> RelativeTimeFormat.t Js.t) | ||||||||||
Js.constr | ||||||||||
|
||||||||||
val is_supported : unit -> bool |
Uh oh!
There was an error while loading. Please reload this page.