calculateEvent method

DateTime? calculateEvent(
  1. DateTime date,
  2. Zenith zenith,
  3. EventType type
)

Calculate the time of an specific sun event

Returns in UTC.

Implementation

DateTime? calculateEvent(DateTime date, Zenith zenith, EventType type) {
  final lastMidnight = DateTime(date.year, date.month, date.day);

  final eventMils = _calculate(date, zenith, type);
  if (eventMils == null) {
    return null;
  }
  final mils = (lastMidnight.millisecondsSinceEpoch + eventMils).floor();
  return DateTime.fromMillisecondsSinceEpoch(mils, isUtc: true);
}