fromDateTime function
Converts a DateTime into a TimeFlipEvent. If is12 is true, converts to 12-hour format (with period), otherwise leaves as 24-hour.
Implementation
TimeFlipEvent fromDateTime(DateTime dt, bool is12) {
int hour = dt.hour;
int minute = dt.minute;
int second = dt.second;
if (is12) {
int hour12 = hour % 12 == 0 ? 12 : hour % 12;
String period = hour < 12 ? "AM" : "PM";
return TimeFlipEvent(hour: hour12, minute: minute, second: second, period: period);
} else {
return TimeFlipEvent(hour: hour, minute: minute, second: second, period: null);
}
}