ExtendedDuration constructor
ExtendedDuration({})
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;
}