mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Timezone fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5664 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1a92814749
commit
98f56b39be
2 changed files with 65 additions and 32 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Wed Jan 5 14:37:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSTimeZone.m: Changed order of lookup to determine the local
|
||||
timezone:
|
||||
1. User defaults with key 'Local Time Zone'
|
||||
2. GNUSTEP_TZ environment variable
|
||||
3. $GNUSTEP_SYSTEM_ROOT/Libraries/Resources/NSTimeZones/localtime
|
||||
4. TZ environment variable
|
||||
5. Use UTC
|
||||
This means that the TZ environment variable can now safely be used for
|
||||
non-GNUstep timezones as long as GNUSTEP_TZ is defined (or a localtime)
|
||||
file exists.
|
||||
|
||||
Wed Jan 5 10:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* NSTimeZones/NSTimeZones.tar: Made a revised set of timezones with
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
2038 problem.)
|
||||
|
||||
The local time zone can be specified with the user defaults
|
||||
database, the TZ environment variable, the file LOCAL_TIME_FILE, or
|
||||
the fallback time zone (which is UTC), with the ones listed first
|
||||
having precedence.
|
||||
database, the GNUSTEP_TZ environment variable, the file LOCAL_TIME_FILE,
|
||||
the TZ environment variable, or the fallback time zone (which is UTC),
|
||||
with the ones listed first having precedence.
|
||||
|
||||
Any time zone must be a file name in ZONES_DIR.
|
||||
|
||||
|
@ -571,41 +571,61 @@ static NSMapTable *absolutes = 0;
|
|||
zoneDictionary = [[NSMutableDictionary alloc] init];
|
||||
|
||||
localZoneString = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey: LOCALDBKEY];
|
||||
stringForKey: LOCALDBKEY];
|
||||
if (localZoneString == nil)
|
||||
/* Try to get timezone from environment. */
|
||||
localZoneString = [[[NSProcessInfo processInfo]
|
||||
environment] objectForKey: @"TZ"];
|
||||
{
|
||||
/*
|
||||
* Try to get timezone from GNUSTEP_TZ environment variable.
|
||||
*/
|
||||
localZoneString = [[[NSProcessInfo processInfo]
|
||||
environment] objectForKey: @"GNUSTEP_TZ"];
|
||||
}
|
||||
if (localZoneString == nil)
|
||||
/* Try to get timezone from LOCAL_TIME_FILE. */
|
||||
{
|
||||
NSString *f = [NSTimeZone getLocalTimeFile];
|
||||
char zone_name[80];
|
||||
FILE *fp;
|
||||
{
|
||||
/*
|
||||
* Try to get timezone from LOCAL_TIME_FILE.
|
||||
*/
|
||||
NSString *f = [NSTimeZone getLocalTimeFile];
|
||||
char zone_name[80];
|
||||
FILE *fp;
|
||||
|
||||
if (f)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
fp = fopen([f fileSystemRepresentation], "rb");
|
||||
#else
|
||||
fp = fopen([f fileSystemRepresentation], "r");
|
||||
#endif
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (fscanf(fp, "%79s", zone_name) == 1)
|
||||
localZoneString = [NSString stringWithCString: zone_name];
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f != 0)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
fp = fopen([f fileSystemRepresentation], "rb");
|
||||
#else
|
||||
fp = fopen([f fileSystemRepresentation], "r");
|
||||
#endif
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (fscanf(fp, "%79s", zone_name) == 1)
|
||||
localZoneString = [NSString stringWithCString: zone_name];
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localZoneString == nil)
|
||||
{
|
||||
/*
|
||||
* Try to get timezone from standard unix environment variable.
|
||||
*/
|
||||
localZoneString = [[[NSProcessInfo processInfo]
|
||||
environment] objectForKey: @"TZ"];
|
||||
}
|
||||
if (localZoneString != nil)
|
||||
localTimeZone = [NSTimeZone timeZoneWithName: localZoneString];
|
||||
{
|
||||
localTimeZone = [NSTimeZone timeZoneWithName: localZoneString];
|
||||
}
|
||||
else
|
||||
NSLog(@"No local time zone specified.");
|
||||
{
|
||||
NSLog(@"No local time zone specified.");
|
||||
}
|
||||
|
||||
/* If local time zone fails to allocate, then allocate something
|
||||
that is sure to succeed (unless we run out of memory, of
|
||||
course). */
|
||||
/*
|
||||
* If local time zone fails to allocate, then allocate something
|
||||
* that is sure to succeed (unless we run out of memory, of
|
||||
* course).
|
||||
*/
|
||||
if (localTimeZone == nil)
|
||||
{
|
||||
NSLog(@"Using time zone with absolute offset 0.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue