StructureFoundation5.9.0
TimeZone
TimeZone
defines the behavior of a time zone. Time zone values represent geopolitical regions. Consequently, these values have names for these regions. Time zone values also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT) and an abbreviation (such as PST for Pacific Standard Time).
struct TimeZone
TimeZone
provides two static functions to get time zone values: current
and autoupdatingCurrent
. The autoupdatingCurrent
time zone automatically tracks updates made by the user.
Note that time zone database entries such as “America/Los_Angeles” are IDs, not names. An example of a time zone name is “Pacific Daylight Time”. Although many TimeZone
functions include the word “name”, they refer to IDs.
Cocoa does not provide any API to change the time zone of the computer, or of other applications.
Citizens in Foundation
Conformances
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol CustomReflectable
A type that explicitly supplies its own mirror.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol ReferenceConvertible
Decorates types which are backed by a Foundation reference type.
Members
init?(abbreviation: String
) Returns a time zone identified by a given abbreviation.
init(from: Decoder
) throws init?(identifier: String
) Returns a time zone initialized with a given identifier.
init?(secondsFromGMT: Int
) Returns a time zone initialized with a specific number of seconds from GMT.
static var abbreviationDictionary: [String : String]
Returns the mapping of abbreviations to time zone identifiers.
static var autoupdatingCurrent: TimeZone
The time zone currently used by the system, automatically updating to the user’s current preference.
static var current: TimeZone
The time zone currently used by the system.
static var knownTimeZoneIdentifiers: [String]
Returns an array of strings listing the identifier of all the time zones known to the system.
static var timeZoneDataVersion: String
Returns the time zone data version.
var customMirror: Mirror
var debugDescription: String
var description: String
var identifier: String
The geopolitical region identifier that identifies the time zone.
var nextDaylightSavingTimeTransition: Date?
Returns the date of the next (after the current instant) daylight saving time transition for the time zone. Depending on the time zone, the value of this property may represent a change of the time zone’s offset from GMT. Returns
nil
if the time zone does not currently observe daylight saving time.static func == (TimeZone, TimeZone
) -> Bool func abbreviation(for: Date
) -> String? Returns the abbreviation for the time zone at a given date.
func daylightSavingTimeOffset(for: Date
) -> TimeInterval Returns the daylight saving time offset for a given date.
func encode(to: Encoder
) throws func hash(into: inout Hasher
) func isDaylightSavingTime(for: Date
) -> Bool Returns a Boolean value that indicates whether the receiver uses daylight saving time at a given date.
func localizedName(for: NSTimeZone.NameStyle, locale: Locale?
) -> String? Returns the name of the receiver localized for a given locale.
func nextDaylightSavingTimeTransition(after: Date
) -> Date? Returns the next daylight saving time transition after a given date.
func secondsFromGMT(for: Date
) -> Int The current difference in seconds between the time zone and Greenwich Mean Time.
typealias ReferenceType