fix: getTimeTable

This commit is contained in:
4831c0 2025-03-31 20:54:54 +02:00
parent 632575c5a0
commit 75ba255726
Signed by: 4831c0
GPG Key ID: 3F97EDDF98E45AA4

View File

@ -23,11 +23,11 @@ class ApiResponse<T> {
bool cached; bool cached;
ApiResponse( ApiResponse(
this.response, this.response,
this.statusCode, this.statusCode,
this.err, this.err,
this.cached, this.cached,
); );
@override @override
String toString() { String toString() {
@ -211,7 +211,7 @@ class KretaClient {
try { try {
(resp, statusCode) = await _authJson("GET", (resp, statusCode) = await _authJson("GET",
"${KretaEndpoints.getTimeTable(model.iss!)}?" "${KretaEndpoints.getTimeTable(model.iss!)}?"
"datumTol=$fromStr&datumIg=$toStr"); "datumTol=$fromStr&datumIg=$toStr");
if (statusCode >= 400) { if (statusCode >= 400) {
if (cache != null) { if (cache != null) {
@ -309,11 +309,9 @@ class KretaClient {
} }
lessons.sort((a, b) => a.start.compareTo(b.start)); lessons.sort((a, b) => a.start.compareTo(b.start));
lessons.where((lesson) => lessons = lessons.where((lesson) =>
lesson.end.millisecondsSinceEpoch <= from.millisecondsSinceEpoch lesson.start.isAfter(from) && lesson.end.isBefore(to)
&& ).toList();
lesson.start.millisecondsSinceEpoch <= to.millisecondsSinceEpoch
);
return ApiResponse(lessons, 200, err, cached); return ApiResponse(lessons, 200, err, cached);
} }