report source of timezone info.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30529 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-06-01 19:24:07 +00:00
parent 8d598d54aa
commit db6a3bccd4
2 changed files with 22 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2010-06-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSTimeZone.m: add diagnostic to report the source of the
timezone name when we can't create the local timezone.
2010-06-01 Richard Frith-Macdonald <rfm@gnu.org> 2010-06-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/NSPropertyList+GNUstepBase.m: * Source/Additions/NSPropertyList+GNUstepBase.m:

View file

@ -1362,6 +1362,7 @@ static NSMapTable *absolutes = 0;
if (systemTimeZone == nil) if (systemTimeZone == nil)
{ {
NSString *localZoneString = nil; NSString *localZoneString = nil;
NSString *localZoneSource = nil;
/* /*
* setup default value in case something goes wrong. * setup default value in case something goes wrong.
@ -1371,6 +1372,7 @@ static NSMapTable *absolutes = 0;
/* /*
* Try to get timezone from user defaults database * Try to get timezone from user defaults database
*/ */
localZoneSource = _(@"NSUserDefaults: 'Local Time Zone'");
localZoneString = [[NSUserDefaults standardUserDefaults] localZoneString = [[NSUserDefaults standardUserDefaults]
stringForKey: LOCALDBKEY]; stringForKey: LOCALDBKEY];
@ -1379,6 +1381,7 @@ static NSMapTable *absolutes = 0;
*/ */
if (localZoneString == nil) if (localZoneString == nil)
{ {
localZoneSource = _(@"environment variable: 'GNUSTEP_TZ'");
localZoneString = [[[NSProcessInfo processInfo] localZoneString = [[[NSProcessInfo processInfo]
environment] objectForKey: @"GNUSTEP_TZ"]; environment] objectForKey: @"GNUSTEP_TZ"];
} }
@ -1388,6 +1391,8 @@ static NSMapTable *absolutes = 0;
if (localZoneString == nil) if (localZoneString == nil)
{ {
NSString *f = _time_zone_path(LOCAL_TIME_FILE, nil); NSString *f = _time_zone_path(LOCAL_TIME_FILE, nil);
localZoneSource = [NSString stringWithFormat: @"file: '%@'", f];
if (f != nil) if (f != nil)
{ {
localZoneString = [NSString stringWithContentsOfFile: f]; localZoneString = [NSString stringWithContentsOfFile: f];
@ -1399,6 +1404,7 @@ static NSMapTable *absolutes = 0;
*/ */
if (localZoneString == nil) if (localZoneString == nil)
{ {
localZoneSource = _(@"environment variable: 'TZ'");
localZoneString = [[[NSProcessInfo processInfo] localZoneString = [[[NSProcessInfo processInfo]
environment] objectForKey: @"TZ"]; environment] objectForKey: @"TZ"];
} }
@ -1410,6 +1416,8 @@ static NSMapTable *absolutes = 0;
#if defined(HAVE_TZHEAD) && defined(TZDEFAULT) #if defined(HAVE_TZHEAD) && defined(TZDEFAULT)
tzdir = RETAIN([NSString stringWithUTF8String: TZDIR]); tzdir = RETAIN([NSString stringWithUTF8String: TZDIR]);
localZoneString = [NSString stringWithUTF8String: TZDEFAULT]; localZoneString = [NSString stringWithUTF8String: TZDEFAULT];
localZoneSource = [NSString stringWithFormat: @"file: '%@'",
localZoneString];
localZoneString = [localZoneString stringByResolvingSymlinksInPath]; localZoneString = [localZoneString stringByResolvingSymlinksInPath];
#else #else
NSFileManager *dflt = [NSFileManager defaultManager]; NSFileManager *dflt = [NSFileManager defaultManager];
@ -1417,6 +1425,8 @@ static NSMapTable *absolutes = 0;
if ([dflt fileExistsAtPath: SYSTEM_TIME_FILE]) if ([dflt fileExistsAtPath: SYSTEM_TIME_FILE])
{ {
localZoneString = SYSTEM_TIME_FILE; localZoneString = SYSTEM_TIME_FILE;
localZoneSource = [NSString stringWithFormat: @"file: '%@'",
localZoneString];
localZoneString localZoneString
= [localZoneString stringByResolvingSymlinksInPath]; = [localZoneString stringByResolvingSymlinksInPath];
/* Guess what tzdir is */ /* Guess what tzdir is */
@ -1462,6 +1472,7 @@ static NSMapTable *absolutes = 0;
*/ */
if (localZoneString == nil) if (localZoneString == nil)
{ {
localZoneSource = @"function: 'tzset()/tzname'";
tzset(); tzset();
if (tzname[0] != NULL && *tzname[0] != '\0') if (tzname[0] != NULL && *tzname[0] != '\0')
localZoneString = [NSString stringWithUTF8String: tzname[0]]; localZoneString = [NSString stringWithUTF8String: tzname[0]];
@ -1476,6 +1487,7 @@ static NSMapTable *absolutes = 0;
TIME_ZONE_INFORMATION tz; TIME_ZONE_INFORMATION tz;
DWORD DST = GetTimeZoneInformation(&tz); DWORD DST = GetTimeZoneInformation(&tz);
localZoneSource = @"function: 'GetTimeZoneInformation()'";
if (DST == TIME_ZONE_ID_DAYLIGHT) if (DST == TIME_ZONE_ID_DAYLIGHT)
{ {
localZoneString = [NSString stringWithCharacters: tz.DaylightName localZoneString = [NSString stringWithCharacters: tz.DaylightName
@ -1493,6 +1505,11 @@ static NSMapTable *absolutes = 0;
{ {
NSDebugLLog (@"NSTimeZone", @"Using zone %@", localZoneString); NSDebugLLog (@"NSTimeZone", @"Using zone %@", localZoneString);
zone = [defaultPlaceholderTimeZone initWithName: localZoneString]; zone = [defaultPlaceholderTimeZone initWithName: localZoneString];
if (zone == nil)
{
NSLog(@"Unable to create time zone for name: '%@' (source '%@').",
localZoneString, localZoneSource);
}
} }
else else
{ {