diff --git a/lib/api_handler.dart b/lib/api_handler.dart index 4e360d2..a31b570 100644 --- a/lib/api_handler.dart +++ b/lib/api_handler.dart @@ -5,14 +5,7 @@ import 'dart:core'; import 'dart:convert'; import 'transport_helper.dart'; - -String timeOf(DateTime fullDT) { - // doing it this way so we always get two digits on the hour - String full = fullDT.toString(); - List splits = full.split(" ")[1].split(":"); - String time = '${splits[0]}:${splits[1]}'; - return time; -} +import 'utilities.dart'; class ApiHandler { // TODO: Split next line for better Error Handling @@ -79,7 +72,7 @@ class ApiHandler { static Future> departures( String stationId, { int? maxDepartures = -1, - DateTime? time, + DateTime? datetime, int? duration = 0, }) async { String urlPath = '/api/fahrinfo/latest/departureBoard'; @@ -88,8 +81,9 @@ class ApiHandler { Uri url = Uri.https(baseUrl, urlPath, { 'accessId': accessID, 'id': stationString, + 'date': dateOf(datetime ?? DateTime.now()), 'time': timeOf( - time ?? DateTime.now(), + datetime ?? DateTime.now(), ), //time from which departures will be shown 'duration': duration.toString(), //interval time in minutes 'maxJourneys': maxDepartures.toString(), diff --git a/lib/main.dart b/lib/main.dart index 25f8cd8..5f4fbc1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -292,7 +292,7 @@ class _ChooseDeparturePageState extends State { void loadDepartures(Station startStation) async { departureList = await ApiHandler.departures( startStation.id, - time: widget.arrival?.arrivalTime ?? DateTime.now(), + datetime: widget.arrival?.arrivalTime ?? DateTime.now(), ); setState(() {}); } diff --git a/lib/utilities.dart b/lib/utilities.dart new file mode 100644 index 0000000..5996c0c --- /dev/null +++ b/lib/utilities.dart @@ -0,0 +1,13 @@ +String timeOf(DateTime fullDT) { + // doing it this way so we always get two digits on the hour + String full = fullDT.toString(); + List splits = full.split(" ")[1].split(":"); + String time = '${splits[0]}:${splits[1]}'; + return time; +} + +String dateOf(DateTime fullDT) { + String full = fullDT.toString(); + String date = full.split(" ")[0]; + return date; +} \ No newline at end of file