calculateEvent method
Calculate the time of an specific sun event
Returns a UTC DateTime.
Returns null
if the event does not happen.
Implementation
DateTime? calculateEvent(DateTime date, Zenith zenith, EventType type) {
final utcDate = date.toUtc();
final lastMidnight = DateTime.utc(utcDate.year, utcDate.month, utcDate.day);
final eventMils = _calculate(utcDate, zenith, type);
if (eventMils == null) {
return null;
}
final mils = (lastMidnight.millisecondsSinceEpoch + eventMils).floor();
return DateTime.fromMillisecondsSinceEpoch(mils, isUtc: true);
}