Public Access
fix(api_handler): fix wrong date being shown for journeys going past midnight
This commit is contained in:
+4
-10
@@ -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<String> 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<List<Departure>> 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(),
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
|
||||
void loadDepartures(Station startStation) async {
|
||||
departureList = await ApiHandler.departures(
|
||||
startStation.id,
|
||||
time: widget.arrival?.arrivalTime ?? DateTime.now(),
|
||||
datetime: widget.arrival?.arrivalTime ?? DateTime.now(),
|
||||
);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -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<String> 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;
|
||||
}
|
||||
Reference in New Issue
Block a user