Latest 1.1.6
Homepage https://github.com/drtimcooper/LatLongToTimezone
License MIT
Platforms ios 8.0, osx 10.9
Authors

Lat/long to timezone mapper in Java and Swift and C#. Does not require web services or data files.

The "lat/long to timezone polygon mapping" is hardcoded, and we hope this rarely changes, but the changes to offsets and daylight savings changeover dates etc. (which are more frequent) are taken care of by your system libraries and so these are automatically kept up-to-date. From time to time, someone updates the files with the latest timezone polygons, but these rarely change…I think the most recent change is the Crimean peninsular.

99% of people using this project just need the one file:

(Java)
https://github.com/drtimcooper/LatLongToTimezone/blob/master/src/main/java/com/skedgo/converter/TimezoneMapper.java

(Swift)
https://github.com/drtimcooper/LatLongToTimezone/blob/master/Classes/TimezoneMapper.swift

(CSharp)
https://github.com/drtimcooper/LatLongToTimezone/blob/master/Output/Toolbox.TimeAndDate.TimezoneMapper.cs

Install

CocoaPods

# Podfile
use_frameworks!

pod 'LatLongToTimezone', '~> 1.1'

In the Podfile directory, type:

$ pod install

Carthage

Add this to Cartfile

github "drtimcooper/LatLongToTimezone" ~> 1.1
$ carthage update

Versions

For Swift 2.3 and earlier, use version 1.0.4 of the Podspec.
For Swift 3 to 4.1, use version 1.1.3 of the Podspec.
For Swift 4.2 or later, use the latest version.

Usage

In your code, you can do

import LatLongToTimezone

let location = CLLocationCoordinate2D(latitude: 34, longitude: -122)
let timeZone = TimezoneMapper.latLngToTimezone(location)

Latest podspec

{
    "name": "LatLongToTimezone",
    "version": "1.1.6",
    "summary": "Convert a latitude and longitude to a time zone string or TimeZone",
    "description": "Converts a CLLocationCoordinate2D to a time zone identifier or TimeZone.nUses polygonal regions with accuracy at worst ~2km.  Works entirely offline.",
    "homepage": "https://github.com/drtimcooper/LatLongToTimezone",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": {
        "Andrew Kirmse": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "source": {
        "git": "https://github.com/drtimcooper/LatLongToTimezone.git",
        "tag": "1.1.6"
    },
    "source_files": "Classes/*.swift",
    "exclude_files": "Classes/Exclude",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This