TemporalDate.withOffset constructor

TemporalDate.withOffset(
  1. DateTime dateTime,
  2. Duration offset
)

Constructs a new TemporalDate from a Dart DateTime and Duration The time fields (hour, minute, second, etc) are ignored

Implementation

factory TemporalDate.withOffset(DateTime dateTime, Duration offset) {
  if (offset.inDays > 0) {
    throw Exception('Cannot have an offset in days (hh:mm:ss)');
  }

  dateTime = dateTime.toUtc();
  return TemporalDate._(
    DateTime.utc(
      dateTime.year,
      dateTime.month,
      dateTime.day,
    ),
    offset,
  );
}