diff --git a/lib/repository/fdu/bus_repository.dart b/lib/repository/fdu/bus_repository.dart index fc5ddb6f7..278282052 100644 --- a/lib/repository/fdu/bus_repository.dart +++ b/lib/repository/fdu/bus_repository.dart @@ -80,21 +80,24 @@ class BusScheduleItem implements Comparable { BusScheduleItem(this.id, this.start, this.end, this.startTime, this.endTime, this.direction, this.holidayRun); - factory BusScheduleItem.fromRawJson( - Map json) => + factory BusScheduleItem.fromRawJson(Map 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!);