Up

# NSTimeZone class reference

### Authors

Yoo C. Chung (`wacko@laplace.snu.ac.kr`)
Richard Frith-Macdonald (`rfm@gnu.org`)

Date: Generated at 2025-02-13 06:02:40 +0000

Copyright: (C) 1994, 1996, 1999 Free Software Foundation, Inc.

### Contents -

1. Software documentation for the NSTimeZone class
2. Software documentation for the NSTimeZoneDetail class

# Software documentation for the NSTimeZone class

## NSTimeZone : NSObject

> Declared in:
>   Foundation/NSTimeZone.h

Availability: OpenStep

The local time zone is obtained from, in order of preference:
1) the user defaults database: NSGlobalDomain "Local Time Zone"
2) the GNUSTEP_TZ environment variable
3) the file "localtime" in System/Library/Libraries/Resources/NSTimeZone
4) the TZ environment variable
5) The system zone settings (typically in /etc/localtime)
6) tzset and tznam on platforms which have it
7) Windows registry, on Win32 systems
8) or the fallback time zone (which is UTC)

If the GNUstep time zone datafiles become too out of date, one can download an updated database from ftp://elsie.nci.nih.gov/pub/ and compile it as specified in the README file in the NSTimeZones directory.

Time zone names in NSDates should be GMT, MET etc. not Europe/Berlin, America/Washington etc.

The problem with this is that various time zones may use the same abbreviation (e.g. Australia/Brisbane and America/New_York both use EST), and some time zones may have different rules for daylight saving time even if the abbreviation and offsets from UTC are the same.

The problems with depending on the OS for providing time zone info are that time zone names may vary wildly between OSes (this could be a big problem when archiving is used between different systems).

Win32: Time zone names read from the registry are different from other GNUstep installations. Be careful when moving data between platforms in this case.

Method summary

- +abbreviationDictionary
- +abbreviationMap
- +defaultTimeZone
- +knownTimeZoneNames
- +localTimeZone
- +resetSystemTimeZone
- +setDefaultTimeZone:
- +systemTimeZone
- +timeZoneArray
- +timeZoneForSecondsFromGMT:
- +timeZoneWithAbbreviation:
- +timeZoneWithName:
- +timeZoneWithName:data:
- -abbreviation
- -abbreviationForDate:
- -data
- -daylightSavingTimeOffset
- -daylightSavingTimeOffsetForDate:
- -initWithName:
- -initWithName:data:
- -isDaylightSavingTime
- -isDaylightSavingTimeForDate:
- -isEqualToTimeZone:
- -localizedName:locale:
- -name
- -nextDaylightSavingTimeTransition
- -nextDaylightSavingTimeTransitionAfterDate:
- -secondsFromGMT
- -secondsFromGMTForDate:
- -timeZoneDetailArray
- -timeZoneDetailForDate:
- -timeZoneName

### abbreviationDictionary

+ (NSDictionary*) abbreviationDictionary;
Availability: OpenStep
Returns a dictionary containing time zone abbreviations and their corresponding time zone names. More than one time zone may be associated with a single abbreviation. In this case, the dictionary contains only one (usually the most common) time zone name for the abbreviation.

### abbreviationMap

+ (NSDictionary*) abbreviationMap;
Availability: Not in OpenStep/MacOS-X
Returns a dictionary that maps abbreviations to the array containing all the time zone names that use the abbreviation.

### defaultTimeZone

+ (NSTimeZone*) defaultTimeZone;
Availability: OpenStep
Return the default time zone for this process.

### knownTimeZoneNames

+ (NSArray*) knownTimeZoneNames;
Availability: OpenStep
Returns an array of all known time zone names.

### localTimeZone

+ (NSTimeZone*) localTimeZone;
Availability: OpenStep
Return a proxy to the default time zone for this process.

### resetSystemTimeZone

+ (void) resetSystemTimeZone;
Availability: MacOS-X 10.0.0
Destroy the system time zone so that it will be recreated next time it is used.

### setDefaultTimeZone:

+ (void) setDefaultTimeZone: (NSTimeZone*)aTimeZone;
Availability: OpenStep
Set the default time zone to be used for this process.

### systemTimeZone

+ (NSTimeZone*) systemTimeZone;
Availability: MacOS-X 10.0.0
Returns the current system time zone for the process.

### timeZoneArray

+ (NSArray*) timeZoneArray;
Availability: OpenStep
Returns an array of all the known regions.
There are 24 elements, of course, one for each time zone. Each element contains an array of NSStrings which are the region names.

### timeZoneForSecondsFromGMT:

+ (NSTimeZone*) timeZoneForSecondsFromGMT: (NSInteger)seconds;
Availability: OpenStep
Return a timezone for the specified offset from GMT.
The timezone returned does not use daylight savings time. The actual timezone returned has an offset rounded to the nearest minute.
Time zones with an offset of more than +/- 18 hours are disallowed, and `nil` is returned.

### timeZoneWithAbbreviation:

+ (NSTimeZone*) timeZoneWithAbbreviation: (NSString*)abbreviation;
Availability: OpenStep
Returns a timezone for the specified abbreviation. The same abbreviations are used in different regions so this isn't particularly useful.
Calls NSTimeZone-abbreviation dictionary an so uses a lot of memory.

### timeZoneWithName:

+ (NSTimeZone*) timeZoneWithName: (NSString*)aTimeZoneName;
Availability: OpenStep
Returns a timezone for the specified name.

### timeZoneWithName: data:

+ (NSTimeZone*) timeZoneWithName: (NSString*)name data: (NSData*)data;
Availability: MacOS-X 10.0.0
Returns a timezone for aTimeZoneName, created from the supplied time zone data. Data must be in TZ format as per the Olson database.

### abbreviation

- (NSString*) abbreviation;
Availability: MacOS-X 10.0.0
Returns the abbreviation for this timezone now. Invokes -abbreviationForDate:

### abbreviationForDate:

- (NSString*) abbreviationForDate: (NSDate*)aDate;
Availability: MacOS-X 10.0.0
Returns the abbreviation for this timezone at aDate. This may differ depending on whether daylight savings time is in effect or not.

### data

- (NSData*) data;
Availability: MacOS-X 10.0.0
Returns the data with which the receiver was initialised.

### daylightSavingTimeOffset

- (NSTimeInterval) daylightSavingTimeOffset;
Availability: MacOS-X 10.5.0
Description forthcoming.

### daylightSavingTimeOffsetForDate:

- (NSTimeInterval) daylightSavingTimeOffsetForDate: (NSDate*)aDate;
Availability: MacOS-X 10.5.0
Description forthcoming.

### initWithName:

- (id) initWithName: (NSString*)name;
Availability: MacOS-X 10.0.0
Initialise a timezone with the supplied name. May return a cached timezone object rather than the newly created one.

### initWithName: data:

- (id) initWithName: (NSString*)name data: (NSData*)data;
Availability: MacOS-X 10.0.0
Initialises a time zone object using the supplied data object.
This method is intended for internal use by the NSTimeZone class cluster. Don't use it... use -initWithName: instead.

### isDaylightSavingTime

- (BOOL) isDaylightSavingTime;
Availability: MacOS-X 10.0.0
Returns a boolean indicating whether daylight savings time is in effect now. Invokes -isDaylightSavingTimeForDate:

### isDaylightSavingTimeForDate:

- (BOOL) isDaylightSavingTimeForDate: (NSDate*)aDate;
Availability: MacOS-X 10.0.0
Returns a boolean indicating whether daylight savings time is in effect for this time zone at aDate.

### isEqualToTimeZone:

- (BOOL) isEqualToTimeZone: (NSTimeZone*)aTimeZone;
Availability: MacOS-X 10.0.0
Returns `YES` if the time zones have the same name.

### localizedName: locale:

- (NSString*) localizedName: (NSTimeZoneNameStyle)style locale: (NSLocale*)locale;
Availability: MacOS-X 10.5.0
Description forthcoming.

### name

- (NSString*) name;
Availability: MacOS-X 10.0.0
Returns the name of the timezone

### nextDaylightSavingTimeTransition

- (NSDate*) nextDaylightSavingTimeTransition;
Availability: MacOS-X 10.5.0
Description forthcoming.

### nextDaylightSavingTimeTransitionAfterDate:

- (NSDate*) nextDaylightSavingTimeTransitionAfterDate: (NSDate*)aDate;
Availability: MacOS-X 10.5.0
Description forthcoming.

### secondsFromGMT

- (NSInteger) secondsFromGMT;
Availability: MacOS-X 10.0.0
Returns the number of seconds by which the receiver differs from Greenwich Mean Time at the current date and time.
Invokes -secondsFromGMTForDate:

### secondsFromGMTForDate:

- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate;
Availability: MacOS-X 10.0.0
Returns the number of seconds by which the receiver differs from Greenwich Mean Time at the date aDate.
If the time zone uses daylight savings time, the returned value will vary at different times of year.

### timeZoneDetailArray

- (NSArray*) timeZoneDetailArray;
Availability: OpenStep
DEPRECATED: see NSTimeZoneDetail

### timeZoneDetailForDate:

- (NSTimeZoneDetail*) timeZoneDetailForDate: (NSDate*)date;
Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
DEPRECATED: see NSTimeZoneDetail

### timeZoneName

- (NSString*) timeZoneName;
Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
Returns the name of this timezone.

# Software documentation for the NSTimeZoneDetail class

## NSTimeZoneDetail : NSTimeZone

> Declared in:
>   Foundation/NSTimeZone.h

Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
This class serves no useful purpose in GNUstep other than to provide a backup mechanism for handling abbreviations where the precomputed data files cannot be found. It is provided primarily for backward compatibility with the OpenStep spec. It is missing entirely from MacOS-X.
Method summary

- -isDaylightSavingTimeZone
- -timeZoneAbbreviation
- -timeZoneSecondsFromGMT

### isDaylightSavingTimeZone

- (BOOL) isDaylightSavingTimeZone;
Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
DEPRECATED: Class is no longer used.

### timeZoneAbbreviation

- (NSString*) timeZoneAbbreviation;
Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
DEPRECATED: Class is no longer used.

### timeZoneSecondsFromGMT

- (NSInteger) timeZoneSecondsFromGMT;
Availability: OPENSTEP 4.0.0 removed at MacOS-X 10.0.0
DEPRECATED: Class is no longer used.

Up