Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix elapsedTime update and rename wrong func name #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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