From 0016f6e08c30d05444b77aa6c77bf0305134a344 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 1 Jul 2021 23:36:20 -0500 Subject: [PATCH] Use exhaustive switch to catch bugs! --- .../Sources/CoreModelKit/TimezoneData.swift | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift index 649384b..3959b3d 100644 --- a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift +++ b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift @@ -298,28 +298,27 @@ public class TimezoneData: NSObject, NSCoding { public func timezoneFormat(_ currentFormat: NSNumber) -> String { let chosenDefault = currentFormat let timeFormat = TimezoneData.values[chosenDefault] ?? DateFormat.twelveHour - - if overrideFormat == .globalFormat { + + switch overrideFormat { + case .globalFormat: return timeFormat - } else if overrideFormat == .twelveHourFormat { + case .twelveHourFormat: return DateFormat.twelveHour - } else if overrideFormat == .twentyFourFormat { + case .twentyFourFormat: return DateFormat.twentyFourHour - } else if overrideFormat == .twelveHourWithSeconds { + case .twelveHourWithSeconds: return DateFormat.twelveHourWithSeconds - } else if overrideFormat == .twentyHourWithSeconds { + case .twentyHourWithSeconds: return DateFormat.twentyFourHourWithSeconds - } else if overrideFormat == .twelveHourPrecedingZero { + case .twelveHourPrecedingZero: return DateFormat.twelveHourWithZero - } else if overrideFormat == .twelveHourPrecedingZeroSeconds { + case .twelveHourPrecedingZeroSeconds: return DateFormat.twelveHourWithZeroSeconds - } else if overrideFormat == .twelveHourWithoutSuffix { + case .twelveHourWithoutSuffix: return DateFormat.twelveHourWithoutSuffix - } else if overrideFormat == .twelveHourWithoutSuffixAndSeconds { + case .twelveHourWithoutSuffixAndSeconds: return DateFormat.twelveHourWithoutSuffixAndSeconds } - - return timeFormat } public func shouldShowSeconds(_ currentFormat: NSNumber) -> Bool {