Class: NSTimeZone
Overview
NSTimeZone is an abstract class that defines the behavior of time zone objects. Time zone objects represent geopolitical regions. Consequently, these objects have names for these regions. Time zone objects also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT) and an abbreviation (such as PST for Pacific Standard Time).
Class Method Summary (collapse)
-
+ abbreviationDictionary
Returns a dictionary holding the mappings of time zone abbreviations to time zone names.
-
+ defaultTimeZone
Returns the default time zone for the current application.
-
+ knownTimeZoneNames
Returns an array of strings listing the IDs of all the time zones known to the system.
-
+ localTimeZone
Returns an object that forwards all messages to the default time zone for the current application.
-
+ resetSystemTimeZone
Resets the system time zone object cached by the application, if any.
-
+ setAbbreviationDictionary:
Sets the abbreviation dictionary to the specified dictionary.
-
+ setDefaultTimeZone:
Sets the default time zone for the current application to a given time zone.
-
+ systemTimeZone
Returns the time zone currently used by the system.
-
+ timeZoneDataVersion
Returns the time zone data version.
-
+ timeZoneForSecondsFromGMT:
Returns a time zone object offset from Greenwich Mean Time by a given number of seconds.
-
+ timeZoneWithAbbreviation:
Returns the time zone object identified by a given abbreviation.
-
+ timeZoneWithName:
Returns the time zone object identified by a given ID.
-
+ timeZoneWithName:data:
Returns the time zone with a given ID whose data has been initialized using given data, You should not call this method directly—use timeZoneWithName: to get the time zone object for a given name.
Instance Method Summary (collapse)
-
- abbreviation
Returns the abbreviation for the receiver.
-
- abbreviationForDate:
Returns the abbreviation for the receiver at a given date.
-
- data
Returns the data that stores the information used by the receiver.
-
- daylightSavingTimeOffset
Returns the current daylight saving time offset of the receiver.
-
- daylightSavingTimeOffsetForDate:
Returns the daylight saving time offset for a given date.
-
- description
Returns the description of the receiver.
-
- initWithName:
Returns a time zone initialized with a given ID.
-
- initWithName:data:
Initializes a time zone with a given ID and time zone data.
-
- isDaylightSavingTime
Returns a Boolean value that indicates whether the receiver is currently using daylight saving time.
-
- isDaylightSavingTimeForDate:
Returns a Boolean value that indicates whether the receiver uses daylight savings time at a given date.
-
- isEqualToTimeZone:
Returns a Boolean value that indicates whether the receiver has the same name and data as another given time zone.
-
- localizedName:locale:
Returns the name of the receiver localized for a given locale.
-
- name
Returns the geopolitical region ID that identifies the receiver.
-
- nextDaylightSavingTimeTransition
Returns the date of the next daylight saving time transition for the receiver.
-
- nextDaylightSavingTimeTransitionAfterDate:
Returns the next daylight saving time transition after a given date.
-
- secondsFromGMT
Returns the current difference in seconds between the receiver and Greenwich Mean Time.
-
- secondsFromGMTForDate:
Returns the difference in seconds between the receiver and Greenwich Mean Time at a given date.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (Hash) abbreviationDictionary
Returns a dictionary holding the mappings of time zone abbreviations to time zone names. Note that more than one time zone may have the same abbreviation—for example, US/Pacific and Canada/Pacific both use the abbreviation “PST.” In these cases, abbreviationDictionary chooses a single name to map the abbreviation to.
+ (NSTimeZone) defaultTimeZone
Returns the default time zone for the current application. The default time zone is the one that the application is running with, which you can change (so you can make the application run as if it were in a different time zone).If you get the default time zone and hold onto the returned object, it does not change if a subsequent invocation of setDefaultTimeZone: changes the default time zone—you still have the specific time zone you originally got. Contrast this behavior with the object returned by localTimeZone.
+ (Array) knownTimeZoneNames
Returns an array of strings listing the IDs of all the time zones known to the system.
+ (NSTimeZone) localTimeZone
Returns an object that forwards all messages to the default time zone for the current application. The local time zone represents the current state of the default time zone at all times. If you get the default time zone (using defaultTimeZone) and hold onto the returned object, it does not change if a subsequent invocation of setDefaultTimeZone: changes the default time zone—you still have the specific time zone you originally got. The local time zone adds a level of indirection, it acts as if it were the current default time zone whenever you invoke a method on it.
+ (Object) resetSystemTimeZone
Resets the system time zone object cached by the application, if any. If the application has cached the system time zone, this method clears that cached object. If you subsequently invoke systemTimeZone, NSTimeZone will attempt to redetermine the system time zone and a new object will be created and cached (see systemTimeZone).
+ (Object) setAbbreviationDictionary(dict)
Sets the abbreviation dictionary to the specified dictionary.
+ (Object) setDefaultTimeZone(aTimeZone)
Sets the default time zone for the current application to a given time zone. There can be only one default time zone, so by setting a new default time zone, you lose the previous one.
+ (NSTimeZone) systemTimeZone
Returns the time zone currently used by the system.
+ (String) timeZoneDataVersion
Returns the time zone data version.
+ (Object) timeZoneForSecondsFromGMT(seconds)
+ (Object) timeZoneWithAbbreviation(abbreviation)
Returns the time zone object identified by a given abbreviation. In general, you are discouraged from using abbreviations except for unique instances such as “UTC” or “GMT”. Time Zone abbreviations are not standardized and so a given abbreviation may have multiple meanings—for example, “EST” refers to Eastern Time in both the United States and Australia
+ (Object) timeZoneWithName(tzName)
Returns the time zone object identified by a given ID.
+ (Object) timeZoneWithName(tzName, data:data)
Returns the time zone with a given ID whose data has been initialized using given data, You should not call this method directly—use timeZoneWithName: to get the time zone object for a given name.
Instance Method Details
- (String) abbreviation
Returns the abbreviation for the receiver. Invokes abbreviationForDate: with the current date as the argument.
- (String) abbreviationForDate(aDate)
Returns the abbreviation for the receiver at a given date. Note that the abbreviation may be different at different dates. For example, during daylight savings time the US/Eastern time zone has an abbreviation of “EDT.” At other times, its abbreviation is “EST.”
- (NSData) data
Returns the data that stores the information used by the receiver. This data should be treated as an opaque object.
- (NSTimeInterval) daylightSavingTimeOffset
Returns the current daylight saving time offset of the receiver.
- (NSTimeInterval) daylightSavingTimeOffsetForDate(aDate)
Returns the daylight saving time offset for a given date.
- (String) description
Returns the description of the receiver.
- (Object) initWithName(tzName)
Returns a time zone initialized with a given ID. If tzName is a known ID, this method calls initWithName:data: with the appropriate data object.In OS X v10.4 and earlier providing nil for the parameter would have caused a crash. In OS X v10.5 and later, this now raises an invalid argument exception.
- (Object) initWithName(tzName, data:data)
Initializes a time zone with a given ID and time zone data. You should not call this method directly—use initWithName: to get a time zone object.In OS X v10.4 and earlier providing nil for the tzName parameter would have caused a crash. In OS X v10.5 and later, this now raises an invalid argument exception.
- (Boolean) isDaylightSavingTime
Returns a Boolean value that indicates whether the receiver is currently using daylight saving time. This method invokes isDaylightSavingTimeForDate: with the current date as the argument.
- (Boolean) isDaylightSavingTimeForDate(aDate)
Returns a Boolean value that indicates whether the receiver uses daylight savings time at a given date.
- (Boolean) isEqualToTimeZone(aTimeZone)
Returns a Boolean value that indicates whether the receiver has the same name and data as another given time zone.
- (String) localizedName(style, locale:locale)
Returns the name of the receiver localized for a given locale.
- (String) name
Returns the geopolitical region ID that identifies the receiver.
- (NSDate) nextDaylightSavingTimeTransition
Returns the date of the next daylight saving time transition for the receiver.
- (NSDate) nextDaylightSavingTimeTransitionAfterDate(aDate)
Returns the next daylight saving time transition after a given date.
- (Integer) secondsFromGMT
Returns the current difference in seconds between the receiver and Greenwich Mean Time.
- (Integer) secondsFromGMTForDate(aDate)
Returns the difference in seconds between the receiver and Greenwich Mean Time at a given date. The difference may be different from the current difference if the time zone changes its offset from GMT at different points in the year—for example, the U.S. time zones change with daylight savings time.