From 5d66caddfd76b064d3fa6471d7720d37e119f13d Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 20 Sep 2023 18:02:43 +0100 Subject: [PATCH 1/2] Bug fix --- uni/lib/model/entities/lecture.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uni/lib/model/entities/lecture.dart b/uni/lib/model/entities/lecture.dart index 8ff9da9db..1df6d1426 100644 --- a/uni/lib/model/entities/lecture.dart +++ b/uni/lib/model/entities/lecture.dart @@ -25,7 +25,7 @@ class Lecture { String classNumber, int occurrId, ) { - final endTime = startTime.add(Duration(seconds: 60 * 30 * blocks)); + final endTime = startTime.add(Duration(minutes: 30 * blocks)); final lecture = Lecture( subject, typeClass, @@ -62,8 +62,8 @@ class Lecture { day.add(Duration(hours: startTimeHours, minutes: startTimeMinutes)), day.add( Duration( - hours: startTimeMinutes + endTimeHours, - minutes: startTimeMinutes + endTimeMinutes, + hours: endTimeHours, + minutes: endTimeMinutes, ), ), blocks, From 70799b5442c94d3f2c042ec50a3d40e3b61d2b56 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 20 Sep 2023 18:42:49 +0100 Subject: [PATCH 2/2] Code improvement --- uni/lib/model/entities/lecture.dart | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/uni/lib/model/entities/lecture.dart b/uni/lib/model/entities/lecture.dart index 1df6d1426..f91658b2e 100644 --- a/uni/lib/model/entities/lecture.dart +++ b/uni/lib/model/entities/lecture.dart @@ -44,28 +44,25 @@ class Lecture { String subject, String typeClass, DateTime day, - String startTime, + String startTimeString, int blocks, String room, String teacher, String classNumber, int occurrId, ) { - final startTimeHours = int.parse(startTime.substring(0, 2)); - final startTimeMinutes = int.parse(startTime.substring(3, 5)); - final endTimeHours = - (startTimeMinutes + (blocks * 30)) ~/ 60 + startTimeHours; - final endTimeMinutes = (startTimeMinutes + (blocks * 30)) % 60; + final startTime = day.add( + Duration( + hours: int.parse(startTimeString.substring(0, 2)), + minutes: int.parse(startTimeString.substring(3, 5)), + ), + ); + final endTime = startTime.add(Duration(minutes: 30 * blocks)); return Lecture( subject, typeClass, - day.add(Duration(hours: startTimeHours, minutes: startTimeMinutes)), - day.add( - Duration( - hours: endTimeHours, - minutes: endTimeMinutes, - ), - ), + startTime, + endTime, blocks, room, teacher,