mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 07:35:26 +02:00
21 lines
456 B
Dart
21 lines
456 B
Dart
Iterable<DateTime> iterateMonths(
|
|
final DateTime startDate, final DateTime endDate) sync* {
|
|
final endDateLastDay = DateTime(endDate.year, endDate.month, 1);
|
|
|
|
DateTime currentDate = startDate;
|
|
|
|
yield currentDate;
|
|
|
|
while (currentDate != endDateLastDay) {
|
|
final nextDate = DateTime(currentDate.year, currentDate.month + 1, 1);
|
|
|
|
if (nextDate.isAfter(endDate)) {
|
|
break;
|
|
}
|
|
|
|
currentDate = nextDate;
|
|
|
|
yield currentDate;
|
|
}
|
|
}
|