Skip to content

Commit

Permalink
Updates for changes to IANA time zone data.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 31, 2024
1 parent 7072a38 commit 46d19b5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
14 changes: 13 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
2024-12-31 Richard Frith-Macdonald <[email protected]>

* Source/NSTimeZone.m: Add GNUSTEP_BUILTIN_TZ environment variable to
force the use of the IANA standard based time zone files we provide
in the distribution rather than the system supplied time zone data.
This allows us to standardise test behavior across different systems.
* Tests/base/NSCalendarDate/TestInfo: set GNUSTEP_BUILTIN_TZ=1
* Tests/base/NSCalendarDate/test02.m: Change from using the MET zone
to using CET for tests since the IANA data has changed to make MET
behave aas CET.
* Tests/base/NSTimeZone/TestInfo: set GNUSTEP_BUILTIN_TZ=1

2024-11-29 Richard Frith-Macdonald <[email protected]>

* Source/NSURLProtocol.m: fix leaks due to retain loops.
* Source/Additions/NSObject+GNUstepBase.m: fix issues in new
-trackOownership mechanism to log tracked instances at exist and to
-trackOwnership mechanism to log tracked instances at exist and to
handle cases where we track instances of a class and instances of
its subclasses.

Expand Down
24 changes: 16 additions & 8 deletions Source/NSTimeZone.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
Time zone names can be different from system to system, but usually
the user has already set up his timezone independant of GNUstep, so we
should respect that information.
For testing purposes, the GNUSTEP_BUILTIN_TZ environment variable can
be set to force the system independent data to be used.
We do not use a dictionary for storing time zones, since such a
dictionary would be VERY large (~500K). And we would have to use a
Expand Down Expand Up @@ -2500,17 +2502,23 @@ + (NSString*) _getTimeZoneFile: (NSString *)name
}
GS_MUTEX_UNLOCK(zone_mutex);
}
/* Use the system zone info if possible, otherwise, use our installed
info. */
if (tzdir && [[NSFileManager defaultManager] fileExistsAtPath:
[tzdir stringByAppendingPathComponent: name] isDirectory: &isDir] == YES
&& isDir == NO)

if (NO == [[[[NSProcessInfo processInfo] environment]
objectForKey: @"GNUSTEP_BUILTIN_TZ"] boolValue])
{
dir = tzdir;
/* Use the system zone info if possible, otherwise, use our installed
* info.
*/
if (tzdir && [[NSFileManager defaultManager] fileExistsAtPath:
[tzdir stringByAppendingPathComponent: name] isDirectory: &isDir]
&& isDir == NO)
{
dir = tzdir;
}
}
if (dir == nil)
{
dir = _time_zone_path (ZONES_DIR, nil);
dir = _time_zone_path(ZONES_DIR, nil);
}
return [dir stringByAppendingPathComponent: name];
}
Expand Down Expand Up @@ -3065,7 +3073,7 @@ - (id) initWithName: (NSString*)name data: (NSData*)data

NS_DURING
{
size_t nread;
size_t nread;
union input_buffer *up;

lsp = malloc(sizeof(*lsp));
Expand Down
2 changes: 2 additions & 0 deletions Tests/base/NSCalendarDate/TestInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# On unix systems force testing using our inbuilt time zone data.
export GNUSTEP_BUILTIN_TZ=1
32 changes: 16 additions & 16 deletions Tests/base/NSCalendarDate/test02.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ int main()
[tmpArray addObject: @"PM"];
[myLocale setObject: tmpArray forKey: NSAMPMDesignation];

tz = [NSTimeZone timeZoneWithName: @"MET"];
PASS_EQUAL([tz name], @"MET", "got time zone for dates")
tz = [NSTimeZone timeZoneWithName: @"CET"];
PASS_EQUAL([tz name], @"CET", "got time zone for dates")

myBirthday = [NSCalendarDate dateWithYear: 1974
month: 11
day: 20
hour: 13
minute: 0
second: 0
timeZone: tz];
month: 11
day: 20
hour: 13
minute: 0
second: 0
timeZone: tz];
PASS_EQUAL([myBirthday timeZone], tz, "myBirthday has expected time zone")

anotherDay = [NSCalendarDate dateWithYear: 1974
month: 1
day: 2
hour: 3
minute: 0
second: 0
timeZone: tz];
month: 1
day: 2
hour: 3
minute: 0
second: 0
timeZone: tz];
PASS_EQUAL([anotherDay timeZone], tz, "anotherDay has expected time zone")

PASS([[myBirthday descriptionWithCalendarFormat: @"%%"
Expand Down Expand Up @@ -176,7 +176,7 @@ int main()

PASS_EQUAL([myBirthday
descriptionWithCalendarFormat: @"%Z" locale: myLocale],
@"MET", "%%Z format works in description")
@"CET", "%%Z format works in description")

PASS([[myBirthday descriptionWithCalendarFormat: @"%z"
locale: myLocale] isEqualToString: @"+0100"],
Expand All @@ -200,7 +200,7 @@ int main()

PASS_EQUAL([myBirthday
descriptionWithCalendarFormat: @"%H:%M (%Z)" locale: myLocale],
@"13:00 (MET)", "%%H%%M format works in description")
@"13:00 (CET)", "%%H%%M format works in description")

PASS([[myBirthday descriptionWithCalendarFormat: @"%R"
locale: myLocale] isEqualToString: @"13:00"],
Expand Down
3 changes: 3 additions & 0 deletions Tests/base/NSTimeZone/TestInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# On unix systems force testing using our inbuilt time zone data.
export GNUSTEP_BUILTIN_TZ=1

0 comments on commit 46d19b5

Please sign in to comment.