Skip to content

Commit 854202b

Browse files
committed
add Intl.RelativeTime
1 parent 4197fcb commit 854202b

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

lib/js_of_ocaml/intl.ml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,56 @@ module PluralRules = struct
413413
end
414414
end
415415

416+
module RelativeTimeFormat = struct
417+
include Shared
418+
419+
class type resolved_options = object
420+
method locale : Js.js_string Js.t Js.readonly_prop
421+
422+
method style : Js.js_string Js.t Js.readonly_prop
423+
424+
method numberingSystem : Js.js_string Js.t Js.readonly_prop
425+
426+
method numeric : Js.js_string Js.t Js.readonly_prop
427+
end
428+
429+
class type options = object
430+
method localeMatcher : Js.js_string Js.t Js.prop
431+
432+
method numberingSystem : Js.js_string Js.t Js.optdef Js.prop
433+
434+
method style : Js.js_string Js.t Js.optdef Js.prop
435+
436+
method numeric : Js.js_string Js.t Js.optdef Js.prop
437+
end
438+
439+
let options () : options Js.t =
440+
object%js
441+
val mutable localeMatcher = Js.string "best fit"
442+
443+
val mutable style = Js.undefined
444+
445+
val mutable numberingSystem = Js.undefined
446+
447+
val mutable numeric = Js.undefined
448+
end
449+
450+
class type format_part = object
451+
method _type : Js.js_string Js.t Js.readonly_prop
452+
453+
method _value : Js.js_string Js.t Js.readonly_prop
454+
end
455+
456+
class type t = object
457+
method format : (Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.meth
458+
459+
method formatToParts :
460+
Js.number Js.t -> Js.js_string Js.t -> format_part Js.t Js.js_array Js.t Js.meth
461+
462+
method resolvedOptions : unit -> resolved_options Js.t Js.meth
463+
end
464+
end
465+
416466
class type intl = object
417467
method _Collator : Collator._object Js.t Js.readonly_prop
418468

@@ -422,6 +472,8 @@ class type intl = object
422472

423473
method _PluralRules : PluralRules._object Js.t Js.readonly_prop
424474

475+
method _RelativeTimeFormat : RelativeTimeFormat._object Js.t Js.readonly_prop
476+
425477
method getCanonicalLocales :
426478
Js.js_string Js.t Js.js_array Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth
427479
end
@@ -436,4 +488,6 @@ let numberFormat_constr = Js.Unsafe.global##._Intl##._NumberFormat
436488

437489
let pluralRules_constr = Js.Unsafe.global##._Intl##._PluralRules
438490

491+
let relativeTimeFormat_constr = Js.Unsafe.global##._Intl##._RelativeTimeFormat
492+
439493
let is_supported () = Js.Optdef.test intl

lib/js_of_ocaml/intl.mli

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,47 @@ module PluralRules : sig
627627
end
628628
end
629629

630+
module RelativeTimeFormat : sig
631+
include Shared
632+
633+
class type resolved_options = object
634+
method locale : Js.js_string Js.t Js.readonly_prop
635+
636+
method style : Js.js_string Js.t Js.readonly_prop
637+
638+
method numberingSystem : Js.js_string Js.t Js.readonly_prop
639+
640+
method numeric : Js.js_string Js.t Js.readonly_prop
641+
end
642+
643+
class type options = object
644+
method localeMatcher : Js.js_string Js.t Js.prop
645+
646+
method numberingSystem : Js.js_string Js.t Js.optdef Js.prop
647+
648+
method style : Js.js_string Js.t Js.optdef Js.prop
649+
650+
method numeric : Js.js_string Js.t Js.optdef Js.prop
651+
end
652+
653+
val options : unit -> options Js.t
654+
655+
class type format_part = object
656+
method _type : Js.js_string Js.t Js.readonly_prop
657+
658+
method _value : Js.js_string Js.t Js.readonly_prop
659+
end
660+
661+
class type t = object
662+
method format : (Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.meth
663+
664+
method formatToParts :
665+
Js.number Js.t -> Js.js_string Js.t -> format_part Js.t Js.js_array Js.t Js.meth
666+
667+
method resolvedOptions : unit -> resolved_options Js.t Js.meth
668+
end
669+
end
670+
630671
class type intl = object
631672
method _Collator : Collator._object Js.t Js.readonly_prop
632673

@@ -636,6 +677,8 @@ class type intl = object
636677

637678
method _PluralRules : PluralRules._object Js.t Js.readonly_prop
638679

680+
method _RelativeTimeFormat : RelativeTimeFormat._object Js.t Js.readonly_prop
681+
639682
method getCanonicalLocales :
640683
Js.js_string Js.t Js.js_array Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth
641684
end
@@ -666,4 +709,10 @@ val pluralRules_constr :
666709
-> PluralRules.t Js.t)
667710
Js.constr
668711

712+
val relativeTimeFormat_constr :
713+
( Js.js_string Js.t Js.js_array Js.t Js.optdef
714+
-> RelativeTimeFormat.options Js.t Js.optdef
715+
-> RelativeTimeFormat.t Js.t)
716+
Js.constr
717+
669718
val is_supported : unit -> bool

0 commit comments

Comments
 (0)