From 7b18d1240dd9f32071921ba4984355afe83f7c21 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 20 Sep 2023 18:42:49 +0100 Subject: [PATCH] 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,