Skip to content

Commit f97b9a2

Browse files
toastalhhugo
authored andcommitted
add Intl.RelativeTime
1 parent e9cabc0 commit f97b9a2

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

lib/js_of_ocaml/intl.ml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,57 @@ 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 :
458+
(Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.readonly_prop
459+
460+
method formatToParts :
461+
Js.date Js.t Js.optdef -> format_part Js.t Js.js_array Js.t Js.meth
462+
463+
method resolvedOptions : unit -> resolved_options Js.t Js.meth
464+
end
465+
end
466+
416467
class type intl = object
417468
method _Collator : Collator._object Js.t Js.readonly_prop
418469

@@ -422,6 +473,8 @@ class type intl = object
422473

423474
method _PluralRules : PluralRules._object Js.t Js.readonly_prop
424475

476+
method _RelativeTimeFormat : RelativeTimeFormat._object Js.t Js.readonly_prop
477+
425478
method getCanonicalLocales :
426479
Js.js_string Js.t Js.js_array Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth
427480
end
@@ -436,4 +489,6 @@ let numberFormat_constr = Js.Unsafe.global##._Intl##._NumberFormat
436489

437490
let pluralRules_constr = Js.Unsafe.global##._Intl##._PluralRules
438491

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

lib/js_of_ocaml/intl.mli

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,48 @@ 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 :
663+
(Js.number Js.t -> Js.js_string Js.t -> Js.js_string Js.t) Js.readonly_prop
664+
665+
method formatToParts :
666+
Js.date Js.t Js.optdef -> format_part Js.t Js.js_array Js.t Js.meth
667+
668+
method resolvedOptions : unit -> resolved_options Js.t Js.meth
669+
end
670+
end
671+
630672
class type intl = object
631673
method _Collator : Collator._object Js.t Js.readonly_prop
632674

@@ -636,6 +678,8 @@ class type intl = object
636678

637679
method _PluralRules : PluralRules._object Js.t Js.readonly_prop
638680

681+
method _RelativeTimeFormat : RelativeTimeFormat._object Js.t Js.readonly_prop
682+
639683
method getCanonicalLocales :
640684
Js.js_string Js.t Js.js_array Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth
641685
end
@@ -666,4 +710,10 @@ val pluralRules_constr :
666710
-> PluralRules.t Js.t)
667711
Js.constr
668712

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

0 commit comments

Comments
 (0)