Structure
TimeZone
struct TimeZone
Overview
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).
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.
Topics
Operators
Initializers
init?(abbreviation: String)Returns a time zone identified by a given abbreviation.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.
Instance Properties
var identifier: StringThe geopolitical region identifier that identifies the time zone.var nextDaylightSavingTimeTransition: Date?The date of the next (after the current instant) daylight saving time transition for the time zone.
Instance Methods
func abbreviation(for: Date) -> String?Returns the abbreviation for the time zone at a given date.func daylightSavingTimeOffset(for: Date) -> TimeIntervalReturns the daylight saving time offset for a given date.func hash(into: inout Hasher)func isDaylightSavingTime(for: Date) -> BoolReturns a Boolean value that indicates whether the receiver uses daylight saving time at a given date.func localizedName(for: TimeZone.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) -> IntThe current difference in seconds between the time zone and Greenwich Mean Time.
Type Properties
static var abbreviationDictionary: [String : String]Returns the mapping of abbreviations to time zone identifiers.static var autoupdatingCurrent: TimeZoneThe time zone currently used by the system, automatically updating to the user’s current preference.static var current: TimeZoneThe time zone currently used by the system.static var gmt: TimeZonestatic var knownTimeZoneIdentifiers: [String]Returns an array of strings listing the identifier of all the time zones known to the system.static var timeZoneDataVersion: StringReturns the time zone data version.
Enumerations
enum NameStyleEnum you use to specify different name style of a time zone.
Default Implementations
Relationships
Conforms To
Foundation.ReferenceConvertibleSwift.CopyableSwift.CustomDebugStringConvertibleSwift.CustomReflectableSwift.CustomStringConvertibleSwift.DecodableSwift.EncodableSwift.EquatableSwift.EscapableSwift.HashableSwift.SendableSwift.SendableMetatype