Skip to content

Commit

Permalink
fix wrong minuteChange for values < 40
Browse files Browse the repository at this point in the history
  • Loading branch information
creepymonster committed Dec 9, 2021
1 parent a76ae1a commit adc322b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions LibreDirect/Content/SensorReading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ final class SensorReading: CustomStringConvertible, Codable {
init(id: UUID, timestamp: Date, glucoseValue: Double) {
self.id = id
self.timestamp = timestamp.rounded(on: 1, .minute)
self.glucoseValue = glucoseValue
self.readGlucoseValue = glucoseValue
}

// MARK: Internal

let id: UUID
let timestamp: Date
let glucoseValue: Double
let readGlucoseValue: Double

var glucoseValue: Double {
let minReadableGlucose = Double(AppConfig.MinReadableGlucose)
let maxReadableGlucose = Double(AppConfig.MaxReadableGlucose)

if readGlucoseValue < minReadableGlucose {
return minReadableGlucose
} else if readGlucoseValue > maxReadableGlucose {
return maxReadableGlucose
}

return readGlucoseValue
}

var description: String {
[
Expand Down

0 comments on commit adc322b

Please sign in to comment.