Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TrioTests/BolusCalculatorTests/BolusCalculatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ extension BolusCalculatorTests {
/// - Returns: The current decimal value for the specified setting type
private func getCurrentSettingValue(for type: SettingType, at date: Date) async -> Decimal {
let calendar = Calendar.current
let midnight = calendar.startOfDay(for: date)
let minutesSinceMidnight = calendar.dateComponents([.minute], from: midnight, to: date).minute ?? 0
let components = calendar.dateComponents([.hour, .minute], from: date)
let minutesSinceMidnight = (components.hour ?? 0) * 60 + (components.minute ?? 0)

switch type {
case .basal:
Expand Down
5 changes: 3 additions & 2 deletions TrioTests/CoreDataTests/ScheduledBasalInferenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import Testing
[BasalProfileEntry(start: "00:00", minutes: 0, rate: 1.0)]
}

// startOfDay-anchored so all times share one calendar day, matching the sweep's boundary math
// wall-clock anchored so DST transitions don't shift hour/minute semantics
private func time(_ hour: Int, _ minute: Int = 0) -> Date {
Calendar.current.startOfDay(for: Date()).addingTimeInterval(TimeInterval(hour * 3600 + minute * 60))
Calendar.current.date(bySettingHour: hour, minute: minute, second: 0, of: Date()) ?? Calendar.current
.startOfDay(for: Date())
}

private func tempBasal(_ start: Date, _ end: Date) -> TimelineEvent {
Expand Down
Loading