mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
windows timezone fixup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24547 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1fd5c43a7c
commit
901e578015
2 changed files with 61 additions and 38 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2007-02-14 Roland Schwingel <roland.schwingel@onevision.de>
|
||||||
|
|
||||||
|
* Source/NSTimeZone.m: windows bugfix for daylight savings time.
|
||||||
|
|
||||||
2007-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
2007-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSString.m: Don't treat leading '~' in path component or
|
* Source/NSString.m: Don't treat leading '~' in path component or
|
||||||
|
@ -1093,7 +1097,7 @@
|
||||||
|
|
||||||
2006-09-10 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-09-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSTimeZone.m: Remove unnecessary check on fiel name as
|
* Source/NSTimeZone.m: Remove unnecessary check on file name as
|
||||||
Roland Schwingel reported that it caught legitimate files on windows.
|
Roland Schwingel reported that it caught legitimate files on windows.
|
||||||
* Source/NSMessagePort.m:
|
* Source/NSMessagePort.m:
|
||||||
* Source/NSSocketPort.m:
|
* Source/NSSocketPort.m:
|
||||||
|
|
|
@ -1460,37 +1460,22 @@ static NSMapTable *absolutes = 0;
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
/*
|
/*
|
||||||
* Try to get timezone from windows registry.
|
* Try to get timezone from windows system call.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
HKEY regkey;
|
TIME_ZONE_INFORMATION tz;
|
||||||
|
DWORD DST = GetTimeZoneInformation(&tz);
|
||||||
|
|
||||||
if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE,
|
if (DST == TIME_ZONE_ID_DAYLIGHT)
|
||||||
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
|
{
|
||||||
0,
|
localZoneString = [NSString stringWithCharacters: tz.DaylightName
|
||||||
KEY_READ,
|
length: wcslen(tz.DaylightName)];
|
||||||
®key))
|
}
|
||||||
{
|
else
|
||||||
char buf[255];
|
{
|
||||||
DWORD bufsize=255;
|
localZoneString = [NSString stringWithCharacters: tz.StandardName
|
||||||
DWORD type;
|
length: wcslen(tz.StandardName)];
|
||||||
|
}
|
||||||
if (ERROR_SUCCESS == RegQueryValueExA(regkey,
|
|
||||||
"StandardName",
|
|
||||||
0,
|
|
||||||
&type,
|
|
||||||
buf,
|
|
||||||
&bufsize))
|
|
||||||
{
|
|
||||||
bufsize = strlen(buf);
|
|
||||||
while (bufsize && isspace(buf[bufsize-1]))
|
|
||||||
{
|
|
||||||
bufsize--;
|
|
||||||
}
|
|
||||||
localZoneString = [NSString stringWithUTF8String: buf];
|
|
||||||
}
|
|
||||||
RegCloseKey(regkey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2353,12 +2338,36 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
|
|
||||||
GSBreakTime(when, &year, &month, &day, &hour, &minute, &second, &mil);
|
GSBreakTime(when, &year, &month, &day, &hour, &minute, &second, &mil);
|
||||||
|
|
||||||
// Before April or after October is Std
|
// Check north globe
|
||||||
if (month < DaylightDate.wMonth || month > StandardDate.wMonth)
|
if (StandardDate.wMonth >= DaylightDate.wMonth)
|
||||||
return NO;
|
{
|
||||||
// After April and before October is DST
|
// Before April or after October is Std
|
||||||
if (month > DaylightDate.wMonth && month < StandardDate.wMonth)
|
if (month < DaylightDate.wMonth || month > StandardDate.wMonth)
|
||||||
return YES;
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
// After April and before October is DST
|
||||||
|
if (month > DaylightDate.wMonth && month < StandardDate.wMonth)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* check south globe
|
||||||
|
* Before April or after October is DST
|
||||||
|
*/
|
||||||
|
if (month < StandardDate.wMonth || month > DaylightDate.wMonth)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
// After April and before October is Std
|
||||||
|
if (month > StandardDate.wMonth && month < DaylightDate.wMonth)
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dow = ((int)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7;
|
dow = ((int)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7;
|
||||||
if (dow < 0)
|
if (dow < 0)
|
||||||
dow += 7;
|
dow += 7;
|
||||||
|
@ -2396,7 +2405,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
if (mil >= DaylightDate.wMilliseconds)
|
if (mil >= DaylightDate.wMilliseconds)
|
||||||
return YES;
|
return YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if (month == StandardDate.wMonth /* October */)
|
if (month == StandardDate.wMonth /* October */)
|
||||||
{
|
{
|
||||||
daylightdate = day - dow + StandardDate.wDayOfWeek;
|
daylightdate = day - dow + StandardDate.wDayOfWeek;
|
||||||
|
@ -2436,7 +2445,17 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
|
|
||||||
- (NSString*) name
|
- (NSString*) name
|
||||||
{
|
{
|
||||||
return timeZoneName;
|
TIME_ZONE_INFORMATION tz;
|
||||||
|
DWORD DST = GetTimeZoneInformation(&tz);
|
||||||
|
|
||||||
|
if (DST == TIME_ZONE_ID_DAYLIGHT)
|
||||||
|
{
|
||||||
|
return daylightZoneName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return timeZoneName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) secondsFromGMTForDate: (NSDate*)aDate
|
- (int) secondsFromGMTForDate: (NSDate*)aDate
|
||||||
|
@ -2486,7 +2505,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
|
|
||||||
- (NSString*) timeZoneName
|
- (NSString*) timeZoneName
|
||||||
{
|
{
|
||||||
return timeZoneName;
|
return [self name];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue