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 'dart:convert';
|
||||||
|
|
||||||
import 'transport_helper.dart';
|
import 'transport_helper.dart';
|
||||||
|
import 'utilities.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ApiHandler {
|
class ApiHandler {
|
||||||
// TODO: Split next line for better Error Handling
|
// TODO: Split next line for better Error Handling
|
||||||
@@ -79,7 +72,7 @@ class ApiHandler {
|
|||||||
static Future<List<Departure>> departures(
|
static Future<List<Departure>> departures(
|
||||||
String stationId, {
|
String stationId, {
|
||||||
int? maxDepartures = -1,
|
int? maxDepartures = -1,
|
||||||
DateTime? time,
|
DateTime? datetime,
|
||||||
int? duration = 0,
|
int? duration = 0,
|
||||||
}) async {
|
}) async {
|
||||||
String urlPath = '/api/fahrinfo/latest/departureBoard';
|
String urlPath = '/api/fahrinfo/latest/departureBoard';
|
||||||
@@ -88,8 +81,9 @@ class ApiHandler {
|
|||||||
Uri url = Uri.https(baseUrl, urlPath, {
|
Uri url = Uri.https(baseUrl, urlPath, {
|
||||||
'accessId': accessID,
|
'accessId': accessID,
|
||||||
'id': stationString,
|
'id': stationString,
|
||||||
|
'date': dateOf(datetime ?? DateTime.now()),
|
||||||
'time': timeOf(
|
'time': timeOf(
|
||||||
time ?? DateTime.now(),
|
datetime ?? DateTime.now(),
|
||||||
), //time from which departures will be shown
|
), //time from which departures will be shown
|
||||||
'duration': duration.toString(), //interval time in minutes
|
'duration': duration.toString(), //interval time in minutes
|
||||||
'maxJourneys': maxDepartures.toString(),
|
'maxJourneys': maxDepartures.toString(),
|
||||||
|
|||||||
+1
-1
@@ -292,7 +292,7 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
|
|||||||
void loadDepartures(Station startStation) async {
|
void loadDepartures(Station startStation) async {
|
||||||
departureList = await ApiHandler.departures(
|
departureList = await ApiHandler.departures(
|
||||||
startStation.id,
|
startStation.id,
|
||||||
time: widget.arrival?.arrivalTime ?? DateTime.now(),
|
datetime: widget.arrival?.arrivalTime ?? DateTime.now(),
|
||||||
);
|
);
|
||||||
setState(() {});
|
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