Skip to content
Open
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
9 changes: 4 additions & 5 deletions Sources/MagicTimer/MagicTimer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public class MagicTimer {
self.executive = executive
self.backgroundCalculator = backgroundCalculator
self.backgroundCalculator.backgroundTimeCalculateHandler = { elapsedTime in
self.calclulateBackgroundTime(elapsedTime: elapsedTime)
self.calculateBackgroundTime(elapsedTime: elapsedTime)
}
}

Expand Down Expand Up @@ -151,15 +151,15 @@ public class MagicTimer {

// MARK: - Private methods
// It calculates the elapsed time user was in background.
private func calclulateBackgroundTime(elapsedTime: TimeInterval) {
private func calculateBackgroundTime(elapsedTime: TimeInterval) {
switch countMode {
case .stopWatch:
counter.totalCountedValue = elapsedTime
case let .countDown(fromSeconds: countDownSeconds):

let totalCountedValue = countDownSeconds + elapsedTime
let subtraction = countDownSeconds - elapsedTime
if subtraction.isPositive {
counter.totalCountedValue = subtraction
counter.totalCountedValue = totalCountedValue
} else {
counter.totalCountedValue = 1
}
Expand All @@ -180,7 +180,6 @@ public class MagicTimer {
fatalError("The time does not lead to a valid format. Use valid effetiveValue")
}

self.counter.totalCountedValue = fromSeconds
guard counter.totalCountedValue.isBiggerThan(.zero) else {
executive.suspand {
self.lastState = .stopped
Expand Down