Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions crates/perry-runtime/src/intl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::StringHeader;
#[cfg(feature = "intl-segmenter")]
use unicode_segmentation::UnicodeSegmentation;

mod duration_format;
mod locale;
mod locales;
use locales::{get_canonical_locales_thunk, supported_values_of_thunk};
Expand All @@ -28,6 +29,7 @@ const KIND_SEGMENTER: &str = "Segmenter";
const KIND_LIST_FORMAT: &str = "ListFormat";
const KIND_PLURAL_RULES: &str = "PluralRules";
const KIND_RELATIVE_TIME: &str = "RelativeTimeFormat";
const KIND_DURATION_FORMAT: &str = "DurationFormat";

const KEY_KIND: &str = "__intlKind";
const KEY_LOCALE: &str = "__intlLocale";
Expand Down Expand Up @@ -1483,6 +1485,7 @@ fn make_instance(closure: *const ClosureHeader, kind: &str, locales: f64, option
0,
);
}
KIND_DURATION_FORMAT => duration_format::configure(obj, options),
_ => {}
}

Expand Down Expand Up @@ -1833,4 +1836,22 @@ pub fn install_intl_namespace(ns_obj: *mut ObjectHeader) {
),
],
);
install_constructor(
ns_obj,
"DurationFormat",
duration_format::constructor_thunk as *const u8,
&[
("format", duration_format::format_thunk as *const u8, 1),
(
"formatToParts",
duration_format::to_parts_thunk as *const u8,
1,
),
(
"resolvedOptions",
duration_format::resolved_options_thunk as *const u8,
0,
),
],
);
}
Loading
Loading