Skip to content

APTimeZones — the easiest offline way to get NSTimeZone from CLLocation

License

Notifications You must be signed in to change notification settings

donjordano/APTimeZones

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Apple 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);
    } 
}];

If you have improvements or concerns then create an issue and write details.

Email us with other ideas and projects.

About

APTimeZones — the easiest offline way to get NSTimeZone from CLLocation

Resources

License

Stars

Watchers

Forks

Packages

No packages published