From cae2cb19993a5c9e59f380fd38744c61b6fbc083 Mon Sep 17 00:00:00 2001 From: Colin Rafferty Date: Tue, 17 Oct 2017 10:50:43 -0400 Subject: [PATCH] forget about dropOnReboot and always adjust --- Sources/TimeFreeze.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Sources/TimeFreeze.swift b/Sources/TimeFreeze.swift index 0c63ecd..17f8a3a 100644 --- a/Sources/TimeFreeze.swift +++ b/Sources/TimeFreeze.swift @@ -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 { @@ -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 }