Browse Source

Fixes..

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
703c6747fc
  1. 7
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  2. 5
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

7
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -143,10 +143,10 @@ class ClockerUnitTests: XCTestCase {
// The below test might fail outside California or if DST is active!
// CI is calibrated to be on LA timezone!
func testTimeDifference() {
XCTAssertTrue(operations.timeDifference() == ", 10h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())")
XCTAssertTrue(operations.timeDifference() == ", 9h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())")
XCTAssertTrue(californiaOperations.timeDifference() == ", 3h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())")
XCTAssertTrue(floridaOperations.timeDifference() == "", "Difference was unexpectedly: \(floridaOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == ", 18h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == ", 17h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(omahaOperations.timeDifference() == ", an hour behind", "Difference was unexpectedly: \(omahaOperations.timeDifference())")
}
@ -214,7 +214,8 @@ class ClockerUnitTests: XCTestCase {
UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format
dataObject.setShouldOverrideGlobalTimeFormat(0)
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm",
"Unexpected format returned: \(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()))")
dataObject.setShouldOverrideGlobalTimeFormat(1) // 12-Hour Format
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm a")

5
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -198,7 +198,6 @@ public class TimezoneData: NSObject, NSCoding {
} else if shouldOverride == 4 {
overrideFormat = .twelveHourWithSeconds
} else if shouldOverride == 5 {
print("Setting override format to five")
overrideFormat = .twentyHourWithSeconds
} else if shouldOverride == 7 {
overrideFormat = .twelveHourPrecedingZero
@ -273,7 +272,9 @@ public class TimezoneData: NSObject, NSCoding {
return formatInString.contains("ss")
}
let formatInString = TimezoneData.values[NSNumber(integerLiteral: overrideFormat.rawValue)] ?? DateFormat.twelveHour
// We subtract 1 because the timezone format in the dropdown contains 1 extra row for "Respecting global preferences"
let key = NSNumber(integerLiteral: overrideFormat.rawValue - 1)
let formatInString = TimezoneData.values[key] ?? DateFormat.twelveHour
return formatInString.contains("ss")
}

Loading…
Cancel
Save