TimeZoneLocate 0.5.0

TimeZoneLocate 0.5.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
版本最后版本2019年6月
SPM支持 SPM

Anthony Persaud 维护。



TimeZoneLocate

此实用程序是支持捆绑框架的 APTimeZones 库的 Swift 版本。如果您的项目是 Objective-C,我们建议您使用他们的库。

  • 对于 Swift 5 版本,使用版本 ~> 0.5.0
  • 对于 Swift 4 版本,使用版本 ~> 0.4.0
  • 对于 Swift 3 版本,使用版本 ~> 0.3.0
  • 对于 Swift 2 版本,使用版本 ~> 0.1.0

使用方法

    //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)")
    }

安装

要安装它,只需将以下行添加到您的 Podfile 中

pod "TimeZoneLocate"

作者

许可证

TimeZoneLocate 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。