Просмотр исходного кода

Merge pull request #205 from bjorkert/missing-duration

Handling Optional Duration in Basal Data Processing
Jonas Björkert 3 лет назад
Родитель
Сommit
4634ec8649
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      LoopFollow/Controllers/NightScout.swift

+ 1 - 1
LoopFollow/Controllers/NightScout.swift

@@ -1319,7 +1319,7 @@ extension MainViewController {
                 priorDateFormatter.timeZone = TimeZone(abbreviation: "UTC")
                 guard let priorDateString = dateFormatter.date(from: priorStrippedZone) else { continue }
                 let priorDateTimeStamp = priorDateString.timeIntervalSince1970
-                let priorDuration = priorEntry?["duration"] as! Double
+                let priorDuration = priorEntry?["duration"] as? Double ?? 0.0
                 // if difference between time stamps is greater than the duration of the last entry, there is a gap. Give a 15 second leeway on the timestamp
                 if Double( dateTimeStamp - priorDateTimeStamp ) > Double( (priorDuration * 60) + 15 ) {