APTimeZones

by Alterplay

Alterplay / APTimeZones

The easiest offline way to get NSTimeZone from CLLocation by folks from

429 Stars 43 Forks Last release: Not found MIT License 48 Commits 2 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

An utility for iOS and OSX developers to simplify extracting NSTimeZone from a given CLLocation.

You can do the same job by calling Google API or Yahoo API but APTimeZones works locally, offline and with no limits inherented to hosted solutions.

Usage:

//Ukraine location
CLLocation *location = [[CLLocation alloc] initWithLatitude:50.449846
                                                  longitude:30.523629];

NSTimeZone *timeZone = [[APTimeZones sharedInstance] timeZoneWithLocation:location]; NSLog(@"%@", timeZone);

You can use APTimeZones with CLGeocoder as well to receive NSTimeZone for a given city string.

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:@"New York" completionHandler:^(NSArray *placemarks, NSError *error) {
    if (placemarks.count) {
        CLPlacemark *placemark = placemarks[0];
        CLLocation *location = placemark.location;

    NSString *countryCode = placemark.addressDictionary[@"CountryCode"];
    NSTimeZone *timeZone = [[APTimeZones sharedInstance] timeZoneWithLocation:location
                                                                  countryCode:countryCode];
    NSLog(@"%@", timeZone);
} 

}];

Version 1.1:

We've added some handy categories with version 1.1 to make timezones magic even more easy.

CLLocation+APTimeZones CLPlacemark+APTimeZones

    CLLocation *location = ...
    NSLog(@"%@", location.timeZone);

CLPlacemark *placemark = ...;
NSLog(@"%@", placemark.timeZone);

Also, we've added example project that shows APTimeZones usage [Demo Video on YouTube]:

APTimeZones requires ARC.

=======================

Check out all Alterplay's GitHub projects. Email us with other ideas and projects.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.