UtcOffset.fromString constructor

UtcOffset.fromString(
  1. String offset
)

Creates an offset from a string.

See the Rust documentation for try_from_str for more information.

Additional information: 1

Throws TimeZoneInvalidOffsetError on failure.

Implementation

factory UtcOffset.fromString(String offset) {
  final temp = _FinalizedArena();
  final result = _icu4x_UtcOffset_from_string_mv1(offset._utf8AllocIn(temp.arena));
  if (!result.isOk) {
    throw TimeZoneInvalidOffsetError();
  }
  return UtcOffset._fromFfi(result.union.ok, []);
}