DateFormatter.ymWithProvider constructor

DateFormatter.ymWithProvider(
  1. DataProvider provider,
  2. Locale locale, {
  3. DateTimeLength? length,
  4. DateTimeAlignment? alignment,
  5. YearStyle? yearStyle,
})

See the Rust documentation for try_new for more information.

See the Rust documentation for YM for more information.

Additional information: 1, 2, 3

Throws DateTimeFormatterLoadError on failure.

Implementation

factory DateFormatter.ymWithProvider(DataProvider provider, Locale locale, {DateTimeLength? length, DateTimeAlignment? alignment, YearStyle? yearStyle}) {
  final result = _icu4x_DateFormatter_create_ym_with_provider_mv1(provider._ffi, locale._ffi, length != null ? _ResultInt32Void.ok(length.index) : _ResultInt32Void.err(), alignment != null ? _ResultInt32Void.ok(alignment.index) : _ResultInt32Void.err(), yearStyle != null ? _ResultInt32Void.ok(yearStyle.index) : _ResultInt32Void.err());
  if (!result.isOk) {
    throw DateTimeFormatterLoadError.values.firstWhere((v) => v._ffi == result.union.err);
  }
  return DateFormatter._fromFfi(result.union.ok, []);
}