From 0d185dc11119e873105bbea1f871369b2f11f0ed Mon Sep 17 00:00:00 2001 From: Jules Date: Wed, 10 Apr 2024 10:59:10 +0200 Subject: [PATCH] :bug:: small fix date algo --- .../lib/week_schedule/cubit/week_schedule_cubit.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart b/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart index 0401094..6625f0d 100644 --- a/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart +++ b/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart @@ -34,7 +34,7 @@ class WeekScheduleCubit extends Cubit { weekSchedule.expand((week) => week.daySchedules).toList(); // Only find the closest date if initialDate has not been set - initialDate ??= findClosestDate(allEvents); + initialDate = findClosestDate(allEvents); final todayIndex = findTodayIndex(allEvents); @@ -52,10 +52,13 @@ class WeekScheduleCubit extends Cubit { DateTime findClosestDate(List daySchedules) { DateTime currentDate = DateTime.now(); + currentDate = + DateTime(currentDate.year, currentDate.month, currentDate.day); for (var day in daySchedules) { - if (day.date == currentDate) { - currentDate = day.date; + DateTime dayDate = DateTime(day.date.year, day.date.month, day.date.day); + if (dayDate == currentDate) { + currentDate = dayDate; return currentDate; } else { try {