|
|
@@ -312,10 +312,8 @@ struct PopupView: View {
|
|
|
/// Don't allow total carbs to exceed Max IOB setting.
|
|
|
/// Formula: (Current COB + New Carbs) / Carb Ratio = COB Correction Dose
|
|
|
private var cobCardContent: some View {
|
|
|
- // Check if carbs are actually backdated (more than 15 minutes in the past)
|
|
|
- // This ensures we only consider it backdated if the user has deliberately changed the date
|
|
|
- let minutesThreshold = 15.0 // 15 minutes threshold
|
|
|
- let isBackdated = state.date.timeIntervalSinceNow < -minutesThreshold * 60 && state.simulatedDetermination != nil
|
|
|
+ // Check if this is a backdated entry by comparing with the default date using a tolerance
|
|
|
+ let isBackdated = abs(state.date.timeIntervalSince(state.defaultDate)) > 1.0
|
|
|
|
|
|
// Determine COB and carbs to display based on backdating status
|
|
|
let displayedCOB = isBackdated ? (state.simulatedDetermination?.cob ?? Decimal(state.cob)) : Decimal(state.cob)
|