From f1b1eb99374ca60abe64c663f5f7a91462e9c95a Mon Sep 17 00:00:00 2001 From: Abhishek Banthia Date: Mon, 1 May 2017 12:15:35 -0400 Subject: [PATCH] Local timezone added when app is opened the first time. --- Clocker/ApplicationDelegate.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Clocker/ApplicationDelegate.m b/Clocker/ApplicationDelegate.m index 77624f9..ac1433b 100755 --- a/Clocker/ApplicationDelegate.m +++ b/Clocker/ApplicationDelegate.m @@ -84,8 +84,7 @@ void *kContextActivePanel = &kContextActivePanel; NSNumber *opened = [[NSUserDefaults standardUserDefaults] objectForKey:@"noOfTimes"]; if (opened == nil) { - [[NSUserDefaults standardUserDefaults] setObject:[NSMutableArray array] - forKey:CLDefaultPreferenceKey]; + [self getLocalTimezoneObject]; NSInteger noOfTimes = opened.integerValue + 1; NSNumber *noOfTime = @(noOfTimes); [[NSUserDefaults standardUserDefaults] setObject:noOfTime forKey:@"noOfTimes"];; @@ -113,11 +112,24 @@ void *kContextActivePanel = &kContextActivePanel; [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @YES }]; - [[Crashlytics sharedInstance] setDebugMode:NO]; + [[Crashlytics sharedInstance] setDebugMode:YES]; [Fabric with:@[[Crashlytics class]]]; } +- (void)getLocalTimezoneObject +{ + CLTimezoneData *currentTimezoneObject = [[CLTimezoneData alloc] init]; + [currentTimezoneObject setIDForTimezone:[NSTimeZone systemTimeZone].name]; + [currentTimezoneObject setLabelForTimezone:[NSTimeZone systemTimeZone].name]; + [currentTimezoneObject setFormattedAddressForTimezone:[NSTimeZone systemTimeZone].name]; + + CLTimezoneDataOperations *dataOperations = [[CLTimezoneDataOperations alloc] initWithTimezoneData:currentTimezoneObject]; + + [dataOperations save]; + +} + - (void)setupDatabase { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);