@@ -29,7 +29,7 @@ struct Event: CustomDebugStringConvertible {
2929 var timeString : String {
3030 let dateFormatter = DateFormatter ( )
3131 dateFormatter. dateFormat = " E hh:mm a "
32- dateFormatter. timeZone = TimeZone ( identifier: " UTC " ) // Already in ET, dont convert again
32+ dateFormatter. timeZone = TimeZone ( identifier: " America/New_York " )
3333 return dateFormatter. string ( from: time)
3434 }
3535 var title : String
@@ -152,13 +152,17 @@ class ScheduleParser {
152152 let task = URLSession . shared. dataTask ( with: request) { ( data, response, error) in
153153
154154 guard error == nil else {
155- // @TODO: Error handle
155+ DispatchQueue . main. async {
156+ MessageHandler . showScheduleParsingError ( )
157+ }
156158 print ( error!)
157159 return
158160 }
159161
160162 guard let data = data else {
161- // @TODO: Error handle
163+ DispatchQueue . main. async {
164+ MessageHandler . showScheduleParsingError ( )
165+ }
162166 print ( " no data " )
163167 return
164168 }
@@ -175,7 +179,9 @@ class ScheduleParser {
175179
176180 } catch let error {
177181 // @TODO: Error handle (JSON parse error)
178- print ( " it broke " )
182+ DispatchQueue . main. async {
183+ MessageHandler . showScheduleParsingError ( )
184+ }
179185 print ( error)
180186 }
181187 }
@@ -270,7 +276,7 @@ class ScheduleParser {
270276 case 1 : currentEvent. time = stringToDate ( cellText) ?? Date ( )
271277 case 2 : currentEvent. title = cellText
272278 case 3 : currentEvent. location = cellText
273- case 4 : currentEvent. description = cellText
279+ case 4 : currentEvent. description = filterDescription ( cellText)
274280 case 5 : currentEvent. uuid = cellText
275281 default : break
276282 }
@@ -280,6 +286,21 @@ class ScheduleParser {
280286
281287 }
282288
289+ // Strips the description of any HTML
290+ private static func filterDescription( _ text: String ) -> String {
291+
292+ var result = String ( text)
293+
294+ while result. contains ( " < " ) && result. contains ( " > " ) {
295+ let htmlStart = result. firstIndex ( of: " < " ) !
296+ let htmlEnd = result. firstIndex ( of: " > " ) !
297+
298+ result. removeSubrange ( htmlStart... htmlEnd)
299+ }
300+
301+ print ( " Converted \( text) to \( result) " )
302+ return result
303+ }
283304
284305 private static func stringToDate( _ text: String ) -> Date ? {
285306
@@ -296,7 +317,7 @@ class ScheduleParser {
296317
297318 // Build the final date
298319 var dateComponents = DateComponents ( )
299- dateComponents. timeZone = TimeZone ( identifier: " America/New_York " ) // Might not be req'd but works
320+ dateComponents. timeZone = TimeZone ( identifier: " America/New_York " )
300321 dateComponents. year = 2020
301322 dateComponents. month = 2
302323 dateComponents. hour = Calendar . current. component ( . hour, from: convertedTime!)
0 commit comments