Time zone for locations offline in Swift (iOS).
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Updated Swift version. Oct 29, 2018
Pod Static declarations are implicitly final. Using public instead of open. Oct 28, 2018
.gitignore Updated for Swift 4.2 Sep 16, 2018
.swift-version Updated .swift-version to 4 Dec 31, 2017
.travis.yml Initial commit Jan 17, 2016
CHANGELOG.md Bump version. Oct 29, 2018
LICENSE Initial commit Jan 17, 2016
README.md Formatting. Dec 24, 2017
TimeZoneLocate.podspec Updated Swift version. Oct 29, 2018
_Pods.xcodeproj Initial commit Jan 17, 2016

README.md

TimeZoneLocate

This utility is the Swift port of the APTimeZones library with the support for bundled frameworks. If your project is Objective-C, we recommend using theirs.

  • For Swift 4 version, use version ~> 0.4.0.
  • For Swift 3 version, use version ~> 0.3.0.
  • For Swift 2 version, use version ~> 0.1.0.

Usage:

    //San Diego, CA, USA
    let location = CLLocation(latitude: 32.88, longitude: -117.15)

    //TimeZone from extension (fast, synchronous, approximate)
    var timeZone = location.timeZone
    print(timeZone)

    //or calling the class method
    timeZone = TimeZoneLocate.timeZone(location: location)
    print(timeZone)

    //if you have the country code, you can speed things up.
    timeZone = TimeZoneLocate.timeZone(location: location, countryCode: "US")

    // A MORE accurate time zone if you are connected to network. (iOS 9.0 or later)
    location.timeZone { (tz) -> (Void) in
      guard let tz = tz else { return }
      // got a more accureate timezone from the network
      print("Network TimeZone: \(tz.identifier)")
    }

    // Same thing
    TimeZoneLocate.geocodeTimeZone(location: location) { (tz) -> (Void) in
      guard let tz = tz else { return }
      print("Network TimeZone: \(tz.identifier) (class method)")
    }

Installation

To install it, simply add the following line to your Podfile:

pod "TimeZoneLocate"

Authors

License

TimeZoneLocate is available under the MIT license. See the LICENSE file for more info.