TomlPartialTime constructor

TomlPartialTime(
  1. int hour,
  2. int minute,
  3. int second, [
  4. List<int> secondFractions = const [],
])

Creates a partial time.

Throws an ArgumentError when any of the given values is invalid. When no exception is thrown, the time is not necessarily valid on every date and in every time-zone.

Implementation

TomlPartialTime(
  this.hour,
  this.minute,
  this.second, [
  List<int> secondFractions = const [],
]) : secondFractions = List.unmodifiable(secondFractions) {
  if (hour < 0 || hour > 23) throw ArgumentError('Invalid hour: $hour');
  if (minute < 0 || minute > 59) {
    throw ArgumentError('Invalid minute: $minute');
  }

  // Due to leap seconds, the second is allowed to count up to be `60` and
  // not just `59`.
  if (second < 0 || second > 60) {
    throw ArgumentError('Invalid second: $second');
  }

  for (var secondFraction in secondFractions) {
    if (secondFraction < 0 || secondFraction > 999) {
      throw ArgumentError('Invalid fraction of a second: $secondFraction');
    }
  }
}