bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch to add new class method: [NSTimeZone +knownTimeZoneNames]


From: Georg Fleischmann
Subject: Patch to add new class method: [NSTimeZone +knownTimeZoneNames]
Date: Thu, 7 Oct 2004 20:08:27 GMT

I implemented the method [NSTimeZone +knownTimeZoneNames] from the Apple specs.
Here are the small patches to NSTimeZone.h and m.

Georg


2004-10-07  Georg Fleischmann
        * base/Source/NSTimeZone.m
          +knownTimeZoneNames added



*** base/Headers/Foundation/NSTimeZone.h.old    2003-08-01 01:49:30.000000000 
+0200
--- base/Headers/Foundation/NSTimeZone.h        2004-10-07 20:55:42.000000000 
+0200
***************
*** 40,45 ****
--- 40,46 ----

  // Getting Time Zone Information
  + (NSDictionary*) abbreviationDictionary;
+ + (NSArray*) knownTimeZoneNames;

  //Getting Arrays of Time Zones
  + (NSArray*) timeZoneArray;



*** base/Source/NSTimeZone.m.old        2004-09-29 05:49:10.000000000 +0200
--- base/Source/NSTimeZone.m    2004-10-07 22:05:23.000000000 +0200
***************
*** 997,1002 ****
--- 997,1029 ----
    return abbreviationDictionary;
  }

+ /**
+  * Returns an array of all known time zone names.
+  */
+ + (NSArray*) knownTimeZoneNames
+ {
+   static NSArray *namesArray = nil;
+   int i;
+   id temp_array;
+   NSArray *regionsArray, *array;
+
+   /* We create the array only when we need it to reduce overhead. */
+   if (namesArray != nil)
+     return namesArray;
+
+   temp_array = [NSMutableArray array];
+   regionsArray = [self timeZoneArray];
+
+   for (i = 0; i < [regionsArray count]; i++)
+     {
+       array = [regionsArray objectAtIndex:i];
+       [temp_array addObjectsFromArray: array];
+     }
+
+   namesArray = [[NSArray alloc] initWithArray: temp_array];
+   return namesArray;
+ }
+
  + (id) allocWithZone: (NSZone*)z
  {
    if (self == NSTimeZoneClass)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]