From 4ee4567b24289b24d70b9c2ced8eecb94d97ad71 Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Wed, 28 Apr 2004 00:59:03 +0000 Subject: [PATCH] Check time zone abbreviations git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19203 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/NSCalendarDate.m | 7 +++++-- Testing/nsdate.m | 12 ++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6400610bc..e26343af6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. (). + 2004-04-27 Adam Fedor * Source/GSHTTPURLHandle.m: Get debugFile path using diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 42b82d472..bb2ada02f 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -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; diff --git a/Testing/nsdate.m b/Testing/nsdate.m index ccb66c141..1d754651a 100644 --- a/Testing/nsdate.m +++ b/Testing/nsdate.m @@ -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];