formatDatetimeWithCustomTimeZone method

String formatDatetimeWithCustomTimeZone(
  1. DateTime datetime,
  2. TimeZoneInfo timeZone
)

Formats a `DateTime` and `TimeZoneInfo` to a string.

Throws DateTimeFormatError on failure.

Implementation

String formatDatetimeWithCustomTimeZone(DateTime datetime, TimeZoneInfo timeZone) {
  final write = _Write();
  final result = _icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(_ffi, datetime._ffi, timeZone._ffi, write._ffi);
  if (!result.isOk) {
    throw DateTimeFormatError.values.firstWhere((v) => v._ffi == result.union.err);
  }
  return write.finalize();
}