Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
n0shake committed Jul 5, 2021
1 parent bd09d5d commit a476616
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Clocker/Overall App/Foundation + Additions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ extension NSImage.Name {
static let menubarIcon = NSImage.Name("LightModeIcon")
}

extension Data {
public extension Data {
// Extracting this out for tests
public func decode() -> SearchResult? {
func decode() -> SearchResult? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(SearchResult.self, from: self)
Expand All @@ -46,7 +46,7 @@ extension Data {
}
}

public func decodeTimezone() -> Timezone? {
func decodeTimezone() -> Timezone? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(Timezone.self, from: self)
Expand Down
3 changes: 2 additions & 1 deletion Clocker/Overall App/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ extension NetworkManager {
let session = URLSession(configuration: configuration)

guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: encodedPath) else {
let url = URL(string: encodedPath)
else {
completionHandler(nil, unableToGenerateURL)
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions Clocker/Overall App/Reach.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ open class Reach {
}
}

extension ReachabilityStatus {
fileprivate init(reachabilityFlags flags: SCNetworkReachabilityFlags) {
private extension ReachabilityStatus {
init(reachabilityFlags flags: SCNetworkReachabilityFlags) {
let connectionRequired = flags.contains(.connectionRequired)
let isReachable = flags.contains(.reachable)

Expand Down
2 changes: 1 addition & 1 deletion Clocker/Overall App/VersionUpdateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VersionUpdateHandler: NSObject {
private var appStoreCountry: String!
private var applicationVersion: String!
private var applicationBundleID: String = Bundle.main.bundleIdentifier ?? "N/A"
private var updatePriority: VersionUpdateHandlerPriority = VersionUpdateHandlerPriority.defaultPri
private var updatePriority = VersionUpdateHandlerPriority.defaultPri
private var useAllAvailableLanguages: Bool = true
private var onlyPromptIfMainWindowIsAvailable: Bool = true
private var checkAtLaunch: Bool = true
Expand Down
22 changes: 12 additions & 10 deletions Clocker/Panel/Data Layer/TimezoneDataOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CoreModelKit

class TimezoneDataOperations: NSObject {
private var dataObject: TimezoneData!
private lazy var nsCalendar: Calendar = Calendar.autoupdatingCurrent
private lazy var nsCalendar = Calendar.autoupdatingCurrent
private static var gregorianCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)
private static var swiftyCalendar = Calendar(identifier: .gregorian)
private static let currentLocale = Locale.current.identifier
Expand All @@ -22,12 +22,13 @@ extension TimezoneDataOperations {
guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute,
value: sliderValue,
to: Date(),
options: .matchFirst) else {
options: .matchFirst)
else {
assertionFailure("Data was unexpectedly nil")
return CLEmptyString
}
if (dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime) {

if dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime {
let timezone = TimeZone(identifier: dataObject.timezone())
let offset = timezone?.secondsFromGMT(for: newDate) ?? 0
let value = Int(Date().timeIntervalSince1970 + Double(offset))
Expand All @@ -38,7 +39,6 @@ extension TimezoneDataOperations {
format: dataObject.timezoneFormat(DataStore.shared().timezoneFormat()),
timezoneIdentifier: dataObject.timezone(),
locale: Locale.autoupdatingCurrent)


return dateFormatter.string(from: newDate)
}
Expand All @@ -52,7 +52,8 @@ extension TimezoneDataOperations {
guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute,
value: sliderValue,
to: Date(),
options: .matchFirst) else {
options: .matchFirst)
else {
assertionFailure("Data was unexpectedly nil")
return nil
}
Expand Down Expand Up @@ -204,8 +205,8 @@ extension TimezoneDataOperations {
let sourceTimezone = TimeZone.current
let destinationTimezone = TimeZone(identifier: dataObject.timezone())

let sourceGMTOffset: Double = Double(sourceTimezone.secondsFromGMT(for: source))
let destinationGMTOffset: Double = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0)
let sourceGMTOffset = Double(sourceTimezone.secondsFromGMT(for: source))
let destinationGMTOffset = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0)
let interval = destinationGMTOffset - sourceGMTOffset

return Date(timeInterval: interval, since: source)
Expand Down Expand Up @@ -367,12 +368,13 @@ extension TimezoneDataOperations {
to: Date())

guard let lat = dataObject.latitude,
let long = dataObject.longitude else {
let long = dataObject.longitude
else {
assertionFailure("Data was unexpectedly nil.")
return
}

let coordinates: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: lat, longitude: long)
let coordinates = CLLocationCoordinate2D(latitude: lat, longitude: long)

guard let dateForCalculation = currentDate, let solar = Solar(for: dateForCalculation, coordinate: coordinates) else {
return
Expand Down
2 changes: 1 addition & 1 deletion Clocker/Panel/FloatingWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Cocoa
class FloatingWindowController: ParentPanelController {
private var repeater: Repeater?

static var sharedWindow: FloatingWindowController = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier)
static var sharedWindow = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier)

override func windowDidLoad() {
super.windowDidLoad()
Expand Down

0 comments on commit a476616

Please sign in to comment.