getMoonPhaseStatistics static method

Map<MoonPhase, int> getMoonPhaseStatistics(
  1. DateTime startDate,
  2. DateTime endDate
)

احصائيات أطوار القمر في فترة معينة

Implementation

static Map<MoonPhase, int> getMoonPhaseStatistics(
    DateTime startDate, DateTime endDate) {
  Map<MoonPhase, int> statistics = {};

  // تهيئة العداد
  for (MoonPhase phase in MoonPhase.values) {
    statistics[phase] = 0;
  }

  DateTime currentDate = startDate;
  while (currentDate.isBefore(endDate) ||
      currentDate.isAtSameMomentAs(endDate)) {
    MoonPhaseInfo moonInfo = getMoonPhase(currentDate);
    statistics[moonInfo.phase] = statistics[moonInfo.phase]! + 1;
    currentDate = currentDate.add(Duration(days: 1));
  }

  return statistics;
}