|
From: | Adam Fedor |
Subject: | Re: [RFC]: More automatic timezone info. |
Date: | Wed, 3 Sep 2003 10:52:45 -0600 |
On Wednesday, September 3, 2003, at 10:46 AM, Fred Kiefer wrote:
Adam Fedor wrote:Nice patch, what I don't understand is why you did add an #else branch. If tzset() fails we should still use the TZ environment variable.This patches NSTimeZone to use a more standard (Posix?) method of finding the time zone info that's already set on the computer. I think many people could avoid having to set the "Local Time Zone" default.
tzset is supposed to use the TZ variable before checking other places, so the TZ check should be redundant in this case.
Fred+#if HAVE_TZSET + if (localZoneString == nil) + { + /* + * Try to get timezone from tzset and tzname + */ + extern char *tzname[2]; + tzset(); + if (tzname[0] != NULL && *tzname[0] != '\0') + localZoneString = [NSString stringWithCString: tzname[0]]; + } +#else if (localZoneString == nil) { /* @@ -1131,6 +1144,7 @@ static NSMapTable *absolutes = 0; localZoneString = [[[NSProcessInfo processInfo] environment] objectForKey: @"TZ"]; } +#endif if (localZoneString != nil) { zone = [defaultPlaceholderTimeZone initWithName: localZoneString];
[Prev in Thread] | Current Thread | [Next in Thread] |