LocalDate.fromEpochDay constructor

LocalDate.fromEpochDay(
  1. int epochDay, [
  2. CalendarSystem? calendar
])

Constructs an instance from the number of days since the unix epoch, in the specified or ISO calendar system.

Implementation

factory LocalDate.fromEpochDay(int epochDay, [CalendarSystem? calendar]) {
  if (calendar == null) {
    assert(Preconditions.debugCheckArgumentRange(
        'daysSinceEpoch',
        epochDay,
        ICalendarSystem.minDays(CalendarSystem.iso),
        ICalendarSystem.maxDays(CalendarSystem.iso)));
    return LocalDate._trusted(GregorianYearMonthDayCalculator
        .getGregorianYearMonthDayCalendarFromDaysSinceEpoch(epochDay));
  } else {
    return LocalDate._trusted(
        ICalendarSystem.getYearMonthDayCalendarFromDaysSinceEpoch(
            calendar, epochDay));
  }
}