Realtime.fromDuration constructor
Realtime.fromDuration(
- Duration duration
Constructs a Realtime instance from the specified Duration.
Example:
Duration myDuration = Duration(hours: 2, minutes: 30);
Realtime myTime = Realtime.fromDuration(myDuration);
print(myTime.isHourMode); // Output: true
Implementation
factory Realtime.fromDuration(Duration duration) {
var a = duration.days;
var isToday = a == 0;
var isTomorrow = a == 1;
var isYesterday = a == -1;
return Realtime(
today: isToday,
tomorrow: isTomorrow,
yesterday: isYesterday,
days: duration.days,
hours: duration.hours,
minutes: duration.minutes,
seconds: duration.seconds,
milliseconds: duration.milliseconds,
microseconds: duration.microseconds,
);
}