@@ -80,21 +80,24 @@ class BusScheduleItem implements Comparable<BusScheduleItem> {
80
80
BusScheduleItem (this .id, this .start, this .end, this .startTime, this .endTime,
81
81
this .direction, this .holidayRun);
82
82
83
- factory BusScheduleItem .fromRawJson (
84
- Map <String , dynamic > json) =>
83
+ factory BusScheduleItem .fromRawJson (Map <String , dynamic > json) =>
85
84
BusScheduleItem (
86
85
json['id' ],
87
86
CampusEx .fromChineseName (json['start' ]),
88
87
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' ]),
95
90
BusDirection .values[int .parse (json['arrow' ])],
96
91
int .parse (json['holiday' ]) != 0 );
97
92
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
+
98
101
@override
99
102
int compareTo (BusScheduleItem other) =>
100
103
realStartTime! .compareTo (other.realStartTime! );
0 commit comments