pub struct RelativeTimeFormatter { /* private fields */ }
Expand description

A formatter to render locale-sensitive relative time.

§Example

use fixed_decimal::SignedFixedDecimal;
use icu::experimental::relativetime::{
    RelativeTimeFormatter, RelativeTimeFormatterOptions,
};
use icu::locale::locale;
use writeable::assert_writeable_eq;

let relative_time_formatter = RelativeTimeFormatter::try_new_long_second(
    locale!("en").into(),
    RelativeTimeFormatterOptions::default(),
)
.expect("locale should be present");

assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(5i8)),
    "in 5 seconds"
);
assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(-10i8)),
    "10 seconds ago"
);

§Example

use fixed_decimal::SignedFixedDecimal;
use icu::experimental::relativetime::options::Numeric;
use icu::experimental::relativetime::{
    RelativeTimeFormatter, RelativeTimeFormatterOptions,
};
use icu::locale::locale;
use writeable::assert_writeable_eq;

let relative_time_formatter = RelativeTimeFormatter::try_new_short_day(
    locale!("es").into(),
    RelativeTimeFormatterOptions {
        numeric: Numeric::Auto,
    },
)
.expect("locale should be present");

assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(0u8)),
    "hoy"
);
assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(-2i8)),
    "anteayer"
);
assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(2u8)),
    "pasado mañana"
);
assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(15i8)),
    "dentro de 15 d"
);

§Example

use fixed_decimal::SignedFixedDecimal;
use icu::experimental::relativetime::{
    RelativeTimeFormatter, RelativeTimeFormatterOptions,
};
use icu::locale::locale;
use writeable::assert_writeable_eq;

let relative_time_formatter = RelativeTimeFormatter::try_new_narrow_year(
    locale!("bn").into(),
    RelativeTimeFormatterOptions::default(),
)
.expect("locale should be present");

assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(3u8)),
    "৩ বছরে"
);
assert_writeable_eq!(
    relative_time_formatter.format(SignedFixedDecimal::from(-15i8)),
    "১৫ বছর পূর্বে"
);

Implementations§

source§

impl RelativeTimeFormatter

source

pub fn try_new_long_second( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_second_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_second] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_second_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_second] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_second_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongSecondRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_second] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_minute( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_minute_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_minute] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_minute_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_minute] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_minute_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongMinuteRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_minute] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_hour( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_hour_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_hour] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_hour_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_hour] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_hour_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongHourRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_hour] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_day( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_day_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_day] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_day_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_day] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_day_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongDayRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_day] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_week( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_week_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_week] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_week_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_week] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_week_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongWeekRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_week] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_month( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_month_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_month] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_month_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_month] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_month_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongMonthRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_month] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_quarter( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_quarter_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_quarter] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_quarter_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_quarter] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_quarter_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongQuarterRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_quarter] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_long_year( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_long_year_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_year] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_long_year_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_long_year] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_long_year_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<LongYearRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_long_year] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_second( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_second_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_second] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_second_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_second] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_second_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortSecondRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_second] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_minute( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_minute_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_minute] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_minute_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_minute] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_minute_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortMinuteRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_minute] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_hour( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_hour_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_hour] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_hour_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_hour] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_hour_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortHourRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_hour] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_day( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_day_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_day] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_day_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_day] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_day_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortDayRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_day] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_week( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_week_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_week] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_week_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_week] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_week_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortWeekRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_week] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_month( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_month_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_month] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_month_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_month] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_month_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortMonthRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_month] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_quarter( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_quarter_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_quarter] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_quarter_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_quarter] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_quarter_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortQuarterRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_quarter] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_short_year( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_short_year_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_year] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_short_year_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_short_year] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_short_year_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<ShortYearRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_short_year] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_second( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_second_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_second] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_second_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_second] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_second_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowSecondRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_second] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_minute( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_minute_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_minute] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_minute_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_minute] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_minute_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowMinuteRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_minute] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_hour( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_hour_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_hour] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_hour_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_hour] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_hour_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowHourRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_hour] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_day( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_day_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_day] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_day_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_day] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_day_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowDayRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_day] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_week( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_week_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_week] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_week_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_week] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_week_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowWeekRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_week] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_month( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_month_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_month] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_month_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_month] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_month_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowMonthRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_month] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_quarter( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_quarter_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_quarter] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_quarter_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_quarter] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_quarter_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowQuarterRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_quarter] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn try_new_narrow_year( prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

Create a new RelativeTimeFormatter from compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_year_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_year] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_narrow_year_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>

A version of [Self :: try_new_narrow_year] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_narrow_year_unstable<D>( provider: &D, prefs: RelativeTimeFormatterPreferences, options: RelativeTimeFormatterOptions, ) -> Result<Self, DataError>
where D: DataProvider<CardinalV1Marker> + DataProvider<NarrowYearRelativeTimeFormatDataV1Marker> + DataProvider<DecimalSymbolsV2Marker> + DataProvider<DecimalDigitsV1Marker> + ?Sized,

A version of [Self :: try_new_narrow_year] that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn format(&self, value: SignedFixedDecimal) -> FormattedRelativeTime<'_>

Format a value according to the locale and formatting options of RelativeTimeFormatter.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,