isPeriodStarted method

Future<bool> isPeriodStarted()

check if period started

Implementation

Future<bool> isPeriodStarted() async {
  bool periodStart = false;
  DateTime lastPeriodDate = await getPreviousPeriodDate();
  DateTime expEndPeriodDate =
      lastPeriodDate.add(Duration(days: getPeriodDuration()));
  DateTime today = DateTime.now();

  if (today.isAfter(lastPeriodDate) && today.isBefore(expEndPeriodDate)) {
    periodStart = true;
  } else if (today.isAtSameMomentAs(lastPeriodDate) ||
      today.isAtSameMomentAs(expEndPeriodDate)) {
    periodStart = true;
  }

  return periodStart;
}