Skip to content

Commit

Permalink
Schedule displaying wrong times (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes authored Sep 25, 2023
2 parents eda231e + 70799b5 commit b28f2f3
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions uni/lib/model/entities/lecture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: startTimeMinutes + endTimeHours,
minutes: startTimeMinutes + endTimeMinutes,
),
),
startTime,
endTime,
blocks,
room,
teacher,
Expand Down

0 comments on commit b28f2f3

Please sign in to comment.