I have a variable that stores the duration in minutes and I want to add it to current time to create like new variable for a point in time in the future. How can I go about it where it recognises overflowing over 60 minutes and 24 hours?
I wanted to use something like this that I've seen however custom functions/actions doesn't allow me to use this an extension before the function or future call.
extension TimeOfDayExtension on TimeOfDay {
TimeOfDay plusMinutes(int minutes) {
if (minutes == 0) {
return this;
} else {
int mofd = this.hour * 60 + this.minute;
int newMofd = ((minutes % 1440) + mofd + 1440) % 1440;
if (mofd == newMofd) {
return this;
} else {
int newHour = newMofd ~/ 60;
int newMinute = newMofd % 60;
return TimeOfDay(hour: newHour, minute: newMinute);
}
}
}
}