Time.fromMilliseconds constructor
Time.fromMilliseconds(
- int totalMilliseconds
Create a Time
from milliseconds
Implementation
factory Time.fromMilliseconds(int totalMilliseconds) {
final ms = totalMilliseconds % 1000;
var seconds = (totalMilliseconds / 1000).floor();
var minutes = (seconds / 60).floor();
var hours = (minutes / 60).floor();
seconds = seconds % 60;
minutes = minutes % 60;
// 👇️ If you don't want to roll hours over, e.g. 24 to 00
// 👇️ comment (or remove) the line below
// commenting next line gets you `24:00:00` instead of `00:00:00`
// or `36:15:31` instead of `12:15:31`, etc.
hours = hours % 24;
return Time(hour: hours, minute: minutes, second: seconds, millisecond: ms);
}