LocalTime

public struct LocalTime

Undocumented

  • The time of midnight at the start of the day, ‘00:00’.

    Declaration

    Swift

    public static var midNight: LocalTime { get }
  • The time of noon in the middle of the day, ‘12:00’.

    Declaration

    Swift

    public static var noon: LocalTime { get }
  • min

    The minimum supported LocalTime, ‘00:00’. The maximum supported LocalTime, ‘23:59:59.999999999’.

    Declaration

    Swift

    public static var min: LocalTime { get }
  • max

    The maximum supported LocalTime, ‘23:59:59.999999999’. This is the time just before midnight at the end of the day.

    Declaration

    Swift

    public static var max: LocalTime { get }
  • Gets the local time of each hour.

    Declaration

    Swift

    public static func hour(_ hour: Int) -> LocalTime
  • Obtains an instance of LocalTime from a text string such as 10:15:00.

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

    Declaration

    Swift

    public static func parse(_ text: String, clock: Clock) -> LocalTime?

    Parameters

    text

    The text to parse.

    clock

    The Clock instance.

    Return Value

    The parsed local time.

  • Obtains an instance of LocalTime from a text string such as 10:15:00.

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

    Declaration

    Swift

    static public func parse(_ text: String, timeZone: TimeZone = TimeZone.current) -> LocalTime?

    Parameters

    text

    The text to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed local time.

  • Obtains an instance of LocalTime 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) -> LocalTime?

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    clock

    The Clock instance.

    Return Value

    The parsed local time.

  • Obtains an instance of LocalTime from a text string using a specific formatter.

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

    Declaration

    Swift

    static public func parse(_ text: String, formatter: DateFormatter, timeZone: TimeZone = TimeZone.current) -> LocalTime?

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed local time.

  • Gets the hour-of-day field.

    Declaration

    Swift

    public var hour: Int { get set }
  • Gets the minute-of-hour field from 0 to 59.

    Declaration

    Swift

    public var minute: Int { get set }
  • Gets the second-of-minute field from 0 to 59.

    Declaration

    Swift

    public var second: Int { get set }
  • Gets the nano-of-second field from 0 to 999,999,999.

    Declaration

    Swift

    public var nano: Int { get set }
  • Gets the time as seconds of day,

    Declaration

    Swift

    public var secondOfDay: Int { get }
  • Gets the time as nanos of day,

    Declaration

    Swift

    public var nanoOfDay: Int64 { get }
  • Returns an instance of Date.

    Declaration

    Swift

    public func toDate(clock: Clock) -> Date
  • Returns an instance of Date.

    Declaration

    Swift

    public func toDate(timeZone: TimeZone = TimeZone.current) -> Date
  • Returns a copy of this time with the specified field set to a new value.

    Declaration

    Swift

    public func with(component: Component, newValue: Int) -> LocalTime

    Parameters

    component

    The field to set in the result.

    newValue

    The new value of the field in the result.

    Return Value

    An LocalTime based on this with the specified field set.

  • Returns a copy of this LocalTime with the hour-of-day value altered.

    Declaration

    Swift

    public func with(hour: Int) -> LocalTime

    Return Value

    An LocalTime based on this with the specified field set.

  • Returns a copy of this LocalTime with the minute-of-hour value altered.

    Declaration

    Swift

    public func with(minute: Int) -> LocalTime

    Return Value

    An LocalTime based on this with the specified field set.

  • Returns a copy of this LocalTime with the second-of-minute value altered.

    Declaration

    Swift

    public func with(second: Int) -> LocalTime

    Return Value

    An LocalTime based on this with the specified field set.

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

    Declaration

    Swift

    public func with(nano: Int) -> LocalTime

    Return Value

    An LocalTime based on this with the specified field set.

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

    • Results: An LocalTime based on this time with the specified amount added.

    Declaration

    Swift

    public func plus(component: PlusComponent, newValue: Int) -> LocalTime

    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 LocalTime with the specified period in hours added.

    • Results: An LocalTime based on this time with the specified amount added.

    Declaration

    Swift

    public func plus(hour: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in minutes added.

    • Results: An LocalTime based on this time with the specified amount added.

    Declaration

    Swift

    public func plus(minute: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in seconds added.

    • Results: An LocalTime based on this time with the specified amount added.

    Declaration

    Swift

    public func plus(second: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in nanoseconds added.

    • Results: An LocalTime based on this time with the specified amount added.

    Declaration

    Swift

    public func plus(nano: Int) -> LocalTime
  • Returns a copy of this time with the specified amount subtracted.

    • Results: An LocalTime based on this time with the specified amount subtracted.

    Declaration

    Swift

    public func minus(component: PlusComponent, newValue: Int) -> LocalTime

    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 LocalTime with the specified period in hours subtracted.

    • Results: An LocalTime based on this time with the specified amount subtracted.

    Declaration

    Swift

    public func minus(hour: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in minutes subtracted.

    • Results: An LocalTime based on this time with the specified amount subtracted.

    Declaration

    Swift

    public func minus(minute: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in seconds subtracted.

    • Results: An LocalTime based on this time with the specified amount subtracted.

    Declaration

    Swift

    public func minus(second: Int) -> LocalTime
  • Returns a copy of this LocalTime with the specified period in nanoseconds subtracted.

    • Results: An LocalTime based on this time with the specified amount subtracted.

    Declaration

    Swift

    public func minus(nano: Int) -> LocalTime
  • Gets the range of valid values for the specified field.

    Declaration

    Swift

    public func range(_ component: RangeComponent) -> (Int, Int)

    Return Value

    The range of valid values for the field.

  • Calculates the period between this time and another time as a Period.

    Declaration

    Swift

    public func until(endTime: LocalTime) -> Period

    Parameters

    endTime

    The end time, exclusive, which is converted to an LocalTime.

    Return Value

    The Period of time between this time and the end time.

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

    Declaration

    Swift

    public func until(endTime: LocalTime, component: UntilComponent) -> Int64

    Parameters

    endTime

    The end time, exclusive, which is converted to an LocalTime.

    component

    The unit to measure the amount in.

    Return Value

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

  • Formats this time using the specified formatter.

    Declaration

    Swift

    public func format(_ formatter: DateFormatter) -> String

    Return Value

    The formatted date string.

  • Undocumented

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public static func -= (lhs: inout LocalTime, rhs: LocalTime)
  • Creates the current time from the time-zone.

    Declaration

    Swift

    public init(clock: Clock)
  • Creates the current time from the time-zone.

    Declaration

    Swift

    public init(timeZone: TimeZone = TimeZone.current)
  • Creates a local time from an instance of Date.

    Declaration

    Swift

    public init(_ date: Date, clock: Clock)
  • Creates a local time from an instance of Date.

    Declaration

    Swift

    public init(_ date: Date, timeZone: TimeZone = TimeZone.current)
  • Copies an instance of LocalTime.

    Declaration

    Swift

    public init(_ time: LocalTime)
  • Creates an instance of LocalTime from an hour, minute, second and nanosecond.

    Declaration

    Swift

    public init(hour: Int, minute: Int, second: Int = 0, nanoOfSecond: Int = 0)
  • Creates an instance of LocalTime from a second-of-day value.

    Declaration

    Swift

    public init(secondOfDay: Int)
  • Creates an instance of LocalTime from a nanos-of-day value.

    Declaration

    Swift

    public init(nanoOfDay: 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: LocalTime, rhs: LocalTime) -> 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: LocalTime, rhs: LocalTime) -> 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: LocalTime, rhs: LocalTime) -> 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: LocalTime, rhs: LocalTime) -> 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: LocalTime, rhs: LocalTime) -> 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.