Skip to content

Commit

Permalink
fix: #331
Browse files Browse the repository at this point in the history
  • Loading branch information
w568w committed Feb 29, 2024
1 parent 6c04e69 commit 44329a5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/repository/fdu/bus_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,24 @@ class BusScheduleItem implements Comparable<BusScheduleItem> {
BusScheduleItem(this.id, this.start, this.end, this.startTime, this.endTime,
this.direction, this.holidayRun);

factory BusScheduleItem.fromRawJson(
Map<String, dynamic> json) =>
factory BusScheduleItem.fromRawJson(Map<String, dynamic> json) =>
BusScheduleItem(
json['id'],
CampusEx.fromChineseName(json['start']),
CampusEx.fromChineseName(json['end']),
(json['stime'] as String).isNotEmpty
? VagueTime.onlyMMSS(json['stime'])
: null,
(json['etime'] as String).isNotEmpty
? VagueTime.onlyMMSS(json['etime'])
: null,
_parseTime(json['stime']),
_parseTime(json['etime']),
BusDirection.values[int.parse(json['arrow'])],
int.parse(json['holiday']) != 0);

// Some times are using "." as separator, so we need to parse it manually
static VagueTime? _parseTime(String time) {
if (time.isEmpty) {
return null;
}
return VagueTime.onlyMMSS(time.replaceAll(".", ":"));
}

@override
int compareTo(BusScheduleItem other) =>
realStartTime!.compareTo(other.realStartTime!);
Expand Down

0 comments on commit 44329a5

Please sign in to comment.