Instant

public struct Instant

Undocumented

  • Constant for the 1970-01-01T00:00:00Z epoch instant.

    Declaration

    Swift

    public static var epoch: Instant { get }
  • min

    The minimum supported Instant, ‘-1000_000_000-01-01T00:00Z’.

    Declaration

    Swift

    public static var min: Instant { get }
  • max

    The maximum supported Instant, ‘1000_000_000-12-31T23:59:59.999999999Z’.

    Declaration

    Swift

    public static var max: Instant { get }
  • Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.

    Declaration

    Swift

    public var second: Int64 { get set }
  • Gets the number of nanoseconds, later along the time-line, from the start of the second.

    Declaration

    Swift

    public var nano: Int { get set }
  • Converts this instant to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.

    Declaration

    Swift

    public var epochMilli: Int64 { get }
  • Obtains an instance of Instant from a text string such as 2007-12-03T10:15:30.00Z.

    If the input text and date format are mismatched, returns nil.

    Declaration

    Swift

    public static func parse(_ text: String, clock: Clock = Clock.UTC) -> Instant?

    Parameters

    text

    The text to parse.

    clock

    The Clock instance.

    Return Value

    The parsed instant.

  • Obtains an instance of Instant from a text string such as 2007-12-03T10:15:30.00Z.

    If the input text and date format are mismatched, returns nil.

    Declaration

    Swift

    public static func parse(_ text: String, timeZone: TimeZone) -> Instant?

    Parameters

    text

    The text to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed instant.

  • Obtains an instance of Instant from a text string using a specific formatter. If the input text and date format are mismatched, returns nil.

    Declaration

    Swift

    public static func parse(_ text: String, formatter: DateFormatter, clock: Clock = Clock.UTC) -> Instant?

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    clock

    The Clock instance.

    Return Value

    The parsed instant.

  • Obtains an instance of Instant from a text string using a specific formatter. If the input text and date format are mismatched, returns nil.

    Declaration

    Swift

    public static func parse(_ text: String, formatter: DateFormatter, timeZone: TimeZone) -> Instant?

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed instant.

  • Combines this instant with a time-zone to create a ZonedDateTime.

    Declaration

    Swift

    public func toZone(clock: Clock = Clock.current) -> ZonedDateTime
  • Returns a copy of this instant with the specified field set to a new value.

    Declaration

    Swift

    public func with(component: Component, newValue: Int64) -> Instant

    Parameters

    component

    The field to set in the result.

    newValue

    The new value of the field in the result.

    Return Value

    An Instant based on this with the specified field set.

  • Returns a copy of this Instant with the second value altered.

    Declaration

    Swift

    public func with(second: Int64) -> Instant

    Return Value

    An Instant based on this with the specified field set.

  • Returns a copy of this Instant with the nano-of-second value altered.

    Declaration

    Swift

    public func with(nano: Int64) -> Instant

    Return Value

    An Instant based on this with the specified field set.

  • Returns a copy of this instant with the specified amount added.

    • Results: An Instant based on this instant with the specified amount added.

    Declaration

    Swift

    public func plus(component: Component, newValue: Int64) -> Instant

    Parameters

    component

    The unit of the amount to add.

    newValue

    The amount of the unit to add to the result.

  • Returns a copy of this instant with the specified duration in seconds added.

    • Results: An Instant based on this instant with the specified amount added.

    Declaration

    Swift

    public func plus(second: Int64) -> Instant
  • Returns a copy of this instant with the specified duration in milliseconds added.

    • Results: An Instant based on this instant with the specified amount added.

    Declaration

    Swift

    public func plus(milli: Int64) -> Instant
  • Returns a copy of this instant with the specified duration in nanoseconds added.

    • Results: An Instant based on this instant with the specified amount added.

    Declaration

    Swift

    public func plus(nano: Int64) -> Instant
  • Returns a copy of this instant with the specified duration added.

    • Results: An Instant based on this instant with the specified amount added.

    Declaration

    Swift

    public func plus(second: Int64, nano: Int64) -> Instant

    Parameters

    second

    The amount of the second field to add to the result.

    nano

    The amount of the nano-of-second field to add to the result.

  • Returns a copy of this instant with the specified amount subtracted.

    • Results: An Instant based on this instant with the specified amount subtracted.

    Declaration

    Swift

    public func minus(component: Component, newValue: Int64) -> Instant

    Parameters

    component

    The unit of the amount to subtract.

    newValue

    The amount of the unit to subtract to the result.

  • Returns a copy of this instant with the specified duration in seconds subtracted.

    • Results: An Instant based on this instant with the specified amount subtracted.

    Declaration

    Swift

    public func minus(second: Int64) -> Instant
  • Returns a copy of this instant with the specified duration in milliseconds subtracted.

    • Results: An Instant based on this instant with the specified amount subtracted.

    Declaration

    Swift

    public func minus(milli: Int64) -> Instant
  • Returns a copy of this instant with the specified duration in nanoseconds subtracted.

    • Results: An Instant based on this instant with the specified amount subtracted.

    Declaration

    Swift

    public func minus(nano: Int64) -> Instant
  • Returns a copy of this instant with the specified duration subtracted.

    • Results: An Instant based on this instant with the specified amount subtracted.

    Declaration

    Swift

    public func minus(second: Int64, nano: Int64) -> Instant

    Parameters

    second

    The amount of the second field to subtract to the result.

    nano

    The amount of the nano-of-second field to subtract to the result.

  • Calculates the amount of time until another instant in terms of the specified unit.

    Declaration

    Swift

    public func until(endInstant: Instant, component: UntilComponent) -> Int64

    Parameters

    endInstant

    The end date, exclusive, which is converted to an Instant.

    component

    The unit to measure the amount in.

    Return Value

    The amount of time between this instant and the end instant.

  • Undocumented

    Declaration

    Swift

    public static func + (lhs: Instant, rhs: Instant) -> Instant
  • Undocumented

    Declaration

    Swift

    public static func += (lhs: inout Instant, rhs: Instant)
  • Undocumented

    Declaration

    Swift

    public static func - (lhs: Instant, rhs: Instant) -> Instant
  • Undocumented

    Declaration

    Swift

    public static func -= (lhs: inout Instant, rhs: Instant)
  • Creates an instant from an instance of Date.

    Declaration

    Swift

    public init(_ date: Date = Date())
  • Creates an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z.

    Declaration

    Swift

    public init(epochSecond: Int64, nano: Int64 = 0)
  • Creates an instance of Instant using milliseconds from the epoch of 1970-01-01T00:00:00Z.

    Declaration

    Swift

    public init(epochMilli: Int64)
  • Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.

    Declaration

    Swift

    public static func < (lhs: Instant, rhs: Instant) -> Bool
  • Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.

    Declaration

    Swift

    public static func > (lhs: Instant, rhs: Instant) -> Bool
  • Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.

    Declaration

    Swift

    public static func <= (lhs: Instant, rhs: Instant) -> Bool
  • Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.

    Declaration

    Swift

    public static func >= (lhs: Instant, rhs: Instant) -> Bool
  • The hash value.

    Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution.

    Declaration

    Swift

    public var hashValue: Int { get }
  • Returns a Boolean value indicating whether two values are equal.

    Declaration

    Swift

    public static func == (lhs: Instant, rhs: Instant) -> Bool
  • A textual representation of this instance.

    Declaration

    Swift

    public var description: String { get }
  • A textual representation of this instance, suitable for debugging.

    Declaration

    Swift

    public var debugDescription: String { get }
  • The custom mirror for this instance.

    If this type has value semantics, the mirror should be unaffected by subsequent mutations of the instance.

    Declaration

    Swift

    public var customMirror: Mirror { get }
  • Returns the custom playground description for this instance.

    If this type has value semantics, the instance returned should be unaffected by subsequent mutations if possible.

    Declaration

    Swift

    public var playgroundDescription: Any { get }
  • Creates a new instance by decoding from the given decoder.

    This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.

    Declaration

    Swift

    public init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to read data from.

  • Encodes this value into the given encoder.

    If the value fails to encode anything, encoder will encode an empty keyed container in its place.

    This function throws an error if any values are invalid for the given encoder’s format.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to write data to.