Skip to content

Commit 44329a5

Browse files
committed
fix: #331
1 parent 6c04e69 commit 44329a5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/repository/fdu/bus_repository.dart

+11-8
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,24 @@ class BusScheduleItem implements Comparable<BusScheduleItem> {
8080
BusScheduleItem(this.id, this.start, this.end, this.startTime, this.endTime,
8181
this.direction, this.holidayRun);
8282

83-
factory BusScheduleItem.fromRawJson(
84-
Map<String, dynamic> json) =>
83+
factory BusScheduleItem.fromRawJson(Map<String, dynamic> json) =>
8584
BusScheduleItem(
8685
json['id'],
8786
CampusEx.fromChineseName(json['start']),
8887
CampusEx.fromChineseName(json['end']),
89-
(json['stime'] as String).isNotEmpty
90-
? VagueTime.onlyMMSS(json['stime'])
91-
: null,
92-
(json['etime'] as String).isNotEmpty
93-
? VagueTime.onlyMMSS(json['etime'])
94-
: null,
88+
_parseTime(json['stime']),
89+
_parseTime(json['etime']),
9590
BusDirection.values[int.parse(json['arrow'])],
9691
int.parse(json['holiday']) != 0);
9792

93+
// Some times are using "." as separator, so we need to parse it manually
94+
static VagueTime? _parseTime(String time) {
95+
if (time.isEmpty) {
96+
return null;
97+
}
98+
return VagueTime.onlyMMSS(time.replaceAll(".", ":"));
99+
}
100+
98101
@override
99102
int compareTo(BusScheduleItem other) =>
100103
realStartTime!.compareTo(other.realStartTime!);

0 commit comments

Comments
 (0)