groupByDayOfTheWeek method
Implementation
List<TicketsGroupedByTimeFrame> groupByDayOfTheWeek(
DateTime dateWeekStart, DateTime dateWeekEnd) {
final mondayC = TicketsGroupedByTimeFrame(DateTime.monday, {});
final tuesdayC = TicketsGroupedByTimeFrame(DateTime.tuesday, {});
final wednesdayC = TicketsGroupedByTimeFrame(DateTime.wednesday, {});
final thursdayC = TicketsGroupedByTimeFrame(DateTime.thursday, {});
final fridayC = TicketsGroupedByTimeFrame(DateTime.friday, {});
final saturdayC = TicketsGroupedByTimeFrame(DateTime.saturday, {});
final sundayC = TicketsGroupedByTimeFrame(DateTime.sunday, {});
for (final ticket in this) {
if (ticket.date.isAfter(dateWeekStart) &&
ticket.date.isBefore(dateWeekEnd)) {
switch (ticket.date.weekday) {
case DateTime.monday:
mondayC.tickets.add(ticket);
break;
case DateTime.tuesday:
tuesdayC.tickets.add(ticket);
break;
case DateTime.wednesday:
wednesdayC.tickets.add(ticket);
break;
case DateTime.thursday:
thursdayC.tickets.add(ticket);
break;
case DateTime.friday:
fridayC.tickets.add(ticket);
break;
case DateTime.saturday:
saturdayC.tickets.add(ticket);
break;
case DateTime.sunday:
sundayC.tickets.add(ticket);
break;
default:
throw 'ticket ${ticket.toJson()} date is anormal in weekly';
}
}
}
return [
mondayC,
tuesdayC,
wednesdayC,
thursdayC,
fridayC,
saturdayC,
sundayC,
];
}