of method

  1. @override
FortnightPeriod of(
  1. DateTime date
)
override

Returns the period of the given date considering the generator type.

Implementation

@override
FortnightPeriod of(DateTime date) {
  final sixteenth = date.copyWith(day: 16).date;
  if (date.isBefore(sixteenth)) {
    return FortnightPeriod(
      start: date.firstDayOfMonth.date,
      end: sixteenth.subtract(const Duration(microseconds: 1)),
    );
  }
  return FortnightPeriod(
    start: sixteenth,
    end: date.lastDayOfMonth.endOfDay,
  );
}