mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-02 12:51:07 +00:00
Take notice of whether the system time zone changes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26599 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f1d83b9f14
commit
8c16285f1b
2 changed files with 29 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2008-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSTimeZone.m: Monitor to see if the time zone specified in
|
||||||
|
the user defaults system changes. If so, we update the system zone.
|
||||||
|
|
||||||
2008-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
2008-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSLocale.m:
|
* Source/GSLocale.m:
|
||||||
|
|
|
@ -322,7 +322,8 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type)
|
||||||
|
|
||||||
/* Private methods for obtaining resource file names. */
|
/* Private methods for obtaining resource file names. */
|
||||||
@interface NSTimeZone (Private)
|
@interface NSTimeZone (Private)
|
||||||
+ (NSString*) getTimeZoneFile: (NSString*)name;
|
+ (NSString*) _getTimeZoneFile: (NSString*)name;
|
||||||
|
+ (void) _notified: (NSNotification*)n;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,7 +469,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type)
|
||||||
{
|
{
|
||||||
NSString *fileName;
|
NSString *fileName;
|
||||||
|
|
||||||
fileName = [NSTimeZoneClass getTimeZoneFile: name];
|
fileName = [NSTimeZoneClass _getTimeZoneFile: name];
|
||||||
if (fileName == nil
|
if (fileName == nil
|
||||||
|| ![[NSFileManager defaultManager] fileExistsAtPath: fileName])
|
|| ![[NSFileManager defaultManager] fileExistsAtPath: fileName])
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
|
@ -1289,6 +1290,11 @@ static NSMapTable *absolutes = 0;
|
||||||
localTimeZone = [[NSLocalTimeZone alloc] init];
|
localTimeZone = [[NSLocalTimeZone alloc] init];
|
||||||
|
|
||||||
zone_mutex = [GSLazyRecursiveLock new];
|
zone_mutex = [GSLazyRecursiveLock new];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector(_notified:)
|
||||||
|
name: NSUserDefaultsDidChangeNotification
|
||||||
|
object: nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1584,7 +1590,7 @@ static NSMapTable *absolutes = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSString *zonedir = [NSTimeZone getTimeZoneFile: @"WET"];
|
NSString *zonedir = [NSTimeZone _getTimeZoneFile: @"WET"];
|
||||||
|
|
||||||
if (tzdir != nil)
|
if (tzdir != nil)
|
||||||
{
|
{
|
||||||
|
@ -2033,7 +2039,7 @@ static NSString *zoneDirs[] = {
|
||||||
/**
|
/**
|
||||||
* Returns the path to the named zone info file.
|
* Returns the path to the named zone info file.
|
||||||
*/
|
*/
|
||||||
+ (NSString*) getTimeZoneFile: (NSString *)name
|
+ (NSString*) _getTimeZoneFile: (NSString *)name
|
||||||
{
|
{
|
||||||
static BOOL beenHere = NO;
|
static BOOL beenHere = NO;
|
||||||
NSString *dir = nil;
|
NSString *dir = nil;
|
||||||
|
@ -2083,6 +2089,20 @@ static NSString *zoneDirs[] = {
|
||||||
return [dir stringByAppendingPathComponent: name];
|
return [dir stringByAppendingPathComponent: name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void) _notified: (NSNotification*)n
|
||||||
|
{
|
||||||
|
NSString *name;
|
||||||
|
|
||||||
|
/* If the name of the system time zone has changed ...
|
||||||
|
* get a new system time zone.
|
||||||
|
*/
|
||||||
|
name = [[NSUserDefaults standardUserDefaults] stringForKey: LOCALDBKEY];
|
||||||
|
if ([name length] > 0 && [name isEqual: [[self systemTimeZone] name]] == NO)
|
||||||
|
{
|
||||||
|
[self resetSystemTimeZone];
|
||||||
|
[self systemTimeZone];
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue