ExtendedDuration constructor

ExtendedDuration({
  1. int years = 0,
  2. int months = 0,
  3. int weeks = 0,
  4. int days = 0,
  5. int hours = 0,
  6. int minutes = 0,
  7. int seconds = 0,
  8. int milliseconds = 0,
  9. int microseconds = 0,
})

Implementation

ExtendedDuration({
  this.years = 0,
  this.months = 0,
  this.weeks = 0,
  this.days = 0,
  this.hours = 0,
  this.minutes = 0,
  this.seconds = 0,
  this.milliseconds = 0,
  this.microseconds = 0,
}) {
  // Microseconds to Milliseconds
  milliseconds += microseconds ~/ 1000;
  microseconds %= 1000;

  // Milliseconds to Seconds
  seconds += milliseconds ~/ 1000;
  milliseconds %= 1000;

  // Seconds to Minutes
  minutes += seconds ~/ 60;
  seconds %= 60;

  // Minutes to Hours
  hours += minutes ~/ 60;
  minutes %= 60;

  // Hours to Days
  days += hours ~/ 24;
  hours %= 24;

  // Days to Weeks
  weeks += days ~/ 7;
  days %= 7;

  // Weeks to Months
  months += weeks ~/ 4;
  weeks %= 4;

  // Months to Years
  years += months ~/ 12;
  months %= 12;
}