TimeFormatter.withProvider constructor
- DataProvider provider,
- Locale locale, {
- DateTimeLength? length,
- TimePrecision? timePrecision,
- DateTimeAlignment? alignment,
See the Rust documentation for try_new
for more information.
See the Rust documentation for T
for more information.
Additional information: 1, 2, 3
Throws DateTimeFormatterLoadError on failure.
Implementation
factory TimeFormatter.withProvider(DataProvider provider, Locale locale, {DateTimeLength? length, TimePrecision? timePrecision, DateTimeAlignment? alignment}) {
final result = _icu4x_TimeFormatter_create_with_provider_mv1(provider._ffi, locale._ffi, length != null ? _ResultInt32Void.ok(length.index) : _ResultInt32Void.err(), timePrecision != null ? _ResultInt32Void.ok(timePrecision.index) : _ResultInt32Void.err(), alignment != null ? _ResultInt32Void.ok(alignment.index) : _ResultInt32Void.err());
if (!result.isOk) {
throw DateTimeFormatterLoadError.values.firstWhere((v) => v._ffi == result.union.err);
}
return TimeFormatter._fromFfi(result.union.ok, []);
}