TemporalTime.withOffset constructor

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

Constructs a new TemporalTime from a Dart DateTime and Duration The date fields (year, month, day) are ignored

Implementation

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

  dateTime = dateTime.toUtc();
  return TemporalTime._(
    DateTime.utc(
      1970,
      1,
      1,
      dateTime.hour,
      dateTime.minute,
      dateTime.second,
      dateTime.millisecond,
      dateTime.microsecond,
    ),
    offset: offset,
  );
}