Duration constructor

const Duration(
  1. {int days = 0,
  2. int hours = 0,
  3. int minutes = 0,
  4. int seconds = 0,
  5. int milliseconds = 0,
  6. int microseconds = 0}
)

Creates a new Duration object whose value is the sum of all individual parts.

Individual parts can be larger than the number of those parts in the next larger unit. For example, hours can be greater than 23. If this happens, the value overflows into the next larger unit, so 26 hours is the same as 2 hours and one more days. Likewise, values can be negative, in which case they underflow and subtract from the next larger unit.

If the total number of microseconds cannot be represented as an integer value, the number of microseconds might overflow and be truncated to a smaller number of bits, or it might lose precision.

All arguments are 0 by default.

const duration = Duration(days: 1, hours: 8, minutes: 56, seconds: 59,
  milliseconds: 30, microseconds: 10);
print(duration); // 32:56:59.030010

Implementation

const Duration(
    {int days = 0,
    int hours = 0,
    int minutes = 0,
    int seconds = 0,
    int milliseconds = 0,
    int microseconds = 0})
    : this._microseconds(microseconds +
          microsecondsPerMillisecond * milliseconds +
          microsecondsPerSecond * seconds +
          microsecondsPerMinute * minutes +
          microsecondsPerHour * hours +
          microsecondsPerDay * days);