Date.fromCodesInCalendar constructor

Date.fromCodesInCalendar(
  1. String eraCode,
  2. int year,
  3. String monthCode,
  4. int day,
  5. Calendar calendar,
)

Creates a new Date from the given codes, which are interpreted in the given calendar system

An empty era code will treat the year as an extended year

See the Rust documentation for try_new_from_codes for more information.

Throws CalendarError on failure.

Implementation

factory Date.fromCodesInCalendar(String eraCode, int year, String monthCode, int day, Calendar calendar) {
  final temp = _FinalizedArena();
  final result = _icu4x_Date_from_codes_in_calendar_mv1(eraCode._utf8AllocIn(temp.arena), year, monthCode._utf8AllocIn(temp.arena), day, calendar._ffi);
  if (!result.isOk) {
    throw CalendarError.values[result.union.err];
  }
  return Date._fromFfi(result.union.ok, []);
}