forked from BlakeBoxberger/Nitty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldClock.m
More file actions
21 lines (19 loc) · 1010 Bytes
/
Copy pathWorldClock.m
File metadata and controls
21 lines (19 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
WorldClockManager *worldClockManager = [NSClassFromString(@"WorldClockManager") sharedManager];
NSDateFormatter *worldClockDateFormatter;
static void initializeWorldClockDateFormatter() {
worldClockDateFormatter = [[NSDateFormatter alloc] init];
worldClockDateFormatter.dateStyle = NSDateFormatterNoStyle;
worldClockDateFormatter.timeStyle = NSDateFormatterShortStyle;
}
static NSString *getWorldClockString() {
[worldClockManager loadCities];
WorldClockCity *city = [worldClockManager.cities objectAtIndex:0];
worldClockDateFormatter.timeZone = [NSTimeZone timeZoneWithName:city.timeZone];
NSString *timeString = [worldClockDateFormatter stringFromDate:[NSDate date]];
if(!is24Hour) {
char symbol = tolower([timeString characterAtIndex:[timeString length]-2]);
timeString = [timeString substringToIndex: [timeString length]-3];
timeString = [NSString stringWithFormat:@"%@%c", timeString, symbol];
}
return [NSString stringWithFormat:@"%@ %@", city.countryCode, timeString];
}