Skip to content

Commit

Permalink
forget about dropOnReboot and always adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
craffert0 authored and Reflejo committed Oct 18, 2017
1 parent f0d13e8 commit cae2cb1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Sources/TimeFreeze.swift
Expand Up @@ -26,7 +26,7 @@ struct TimeFreeze {
self.uptime = TimeFreeze.systemUptime()
}

init?(from dictionary: [String: TimeInterval], dropOnReboot: Bool = true) {
init?(from dictionary: [String: TimeInterval]) {
guard let uptime = dictionary[kUptimeKey], let timestamp = dictionary[kTimestampKey],
let offset = dictionary[kOffsetKey] else
{
Expand All @@ -37,14 +37,12 @@ struct TimeFreeze {
let currentTimestamp = currentTime()
let currentBoot = currentUptime - currentTimestamp
let previousBoot = uptime - timestamp
if rint(currentBoot) - rint(previousBoot) == 0 {
self.uptime = uptime
self.timestamp = timestamp
} else if !dropOnReboot {
if rint(currentBoot) - rint(previousBoot) != 0 {
self.uptime = currentUptime
self.timestamp = currentTimestamp
} else {
return nil
self.uptime = uptime
self.timestamp = timestamp
}
self.offset = offset
}
Expand Down

0 comments on commit cae2cb1

Please sign in to comment.