Check time zone abbreviations

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19203 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2004-04-28 00:59:03 +00:00
parent 36e9f07725
commit 4ee4567b24
3 changed files with 25 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2004-04-27 Georg Fleischmann
* Source/NSCalendarDate.m:
(-initWithString:calendarFormat:locale:): avoid exception with
time zone abbreviations.
* Testing/nsdate.m: Add test for this. (<fedor@gnu.org>).
2004-04-27 Adam Fedor <fedor@gnu.org>
* Source/GSHTTPURLHandle.m: Get debugFile path using

View file

@ -1083,11 +1083,14 @@ static inline int getDigits(const char *from, char *to, int limit)
{
NSString *z = [NSString stringWithCString: tmpStr];
tz = [NSTimeZone timeZoneWithName: z];
if (tz == nil)
if ([[NSTimeZone abbreviationDictionary] objectForKey: z])
{
tz = [NSTimeZone timeZoneWithAbbreviation: z];
}
else
{
tz = [NSTimeZone timeZoneWithName: z];
}
}
break;

View file

@ -316,6 +316,18 @@ if ([(NSDate*) [NSCalendarDate date] compare:
printf("Failed on 2003/01/06 is week 2\n");
else
printf("All passed\n");
c = [NSCalendarDate dateWithString: @"2004-05-30 00:30:00 HPT"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
c1 = [NSCalendarDate dateWithString: @"2004-05-30 00:30:00 HST"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
printf("date with time zone abbr %s\n", [[c description] cString]);
if ([c isEqual: c1])
printf("Passed date with time zone abbreviation\n");
else
printf("Failed date with time zone abbreviation\n");
}
[pool release];