What NSTimeZone value does an NSDateFormatter use if you don’t pass it in? I’d like to either use the default timeZone value, or pass in a given one. I’d like to do something like this:
- (NSString *) announcementTime{
NSTimeZone *defaultTimeZone; // What does this become?
[self announcementTimeInTimeZone:defaultTimeZone];
}
- (NSString *) announcementTimeInTimeZone:(NSTimeZone *)timeZone{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setTimeZone:timeZone];
return time;
}
What time zone do I want to pass in to my announcementTimeInTimeZone: method? Perhaps [NSTimeZone defaultTimeZone] or [NSTimeZone localTimeZone]. I’m just not sure what the default is and don’t see it documented anywhere.
I could not find any documentation either but I had a play in the debugger and it looks like NSDateFormatter uses defaultTimeZone.
"f" is an NSDateFormatter created just with alloc – init.
As you can see the two time zones are exactly the same, stored at the same address.