LocalDate

public struct LocalDate

Undocumented

  • min

    The minimum supported LocalDate, ‘-999999999-01-01’. This could be used by an application as a far past date.

    Declaration

    Swift

    public static var min: LocalDate { get }
  • max

    The maximum supported LocalDate, ‘+999999999-12-31’. This could be used by an application as a far future date.

    Declaration

    Swift

    public static var max: LocalDate { get }
  • Obtains an instance of LocalDate from a text string such as 2007-12-03.

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

    Declaration

    Swift

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

    Parameters

    text

    The text to parse.

    clock

    The Clock instance.

    Return Value

    The parsed local date.

  • Obtains an instance of LocalDate from a text string such as 2007-12-03.

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

    Declaration

    Swift

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

    Parameters

    text

    The text to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed local date.

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

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    clock

    The Clock instance.

    Return Value

    The parsed local date.

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

    Parameters

    text

    The text to parse.

    formatter

    The formatter to parse.

    timeZone

    The TimeZone instance.

    Return Value

    The parsed local date.

  • Gets the year field.

    Declaration

    Swift

    public var year: Int { get set }
  • Gets the month-of-year field from 1 to 12.

    Declaration

    Swift

    public var month: Int { get set }
  • day

    Gets the day-of-month field.

    Declaration

    Swift

    public var day: Int { get set }
  • Gets the day-of-week field.

    The start of one week is Monday.

    Declaration

    Swift

    public var dayOfWeek: Int { get }

    Return Value

    • Monday = 0
    • Tuesday = 1
    • Wednesday = 2
    • Thursday = 3
    • Friday = 4
    • Saturday = 5
    • Sunday = 6

  • Gets the epoch day count represented by this date.

    Declaration

    Swift

    public var epochDay: Int64 { get }
  • Returns the length of the month represented by this date.

    Declaration

    Swift

    public func lengthOfMonth() -> Int
  • Returns the length of the year represented by this date.

    Declaration

    Swift

    public func lengthOfYear() -> Int
  • Checks if the year is a leap year, according to the ISO proleptic calendar system rules.

    Declaration

    Swift

    public func isLeapYear() -> Bool
  • 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 date with the specified field set to a new value.

    Declaration

    Swift

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

    Parameters

    component

    The field to set in the result.

    newValue

    The new value of the field in the result.

    Return Value

    An LocalDate based on this with the specified field set.

  • Returns a copy of this date with the year altered.

    Declaration

    Swift

    public func with(year: Int) -> LocalDate

    Return Value

    An LocalDate based on this with the specified field set.

  • Returns a copy of this date with the month-of-year altered.

    Declaration

    Swift

    public func with(month: Int) -> LocalDate

    Return Value

    An LocalDate based on this with the specified field set.

  • Returns a copy of this date with the day-of-month altered.

    Declaration

    Swift

    public func with(dayOfMonth: Int) -> LocalDate

    Return Value

    An LocalDate based on this with the specified field set.

  • Returns a copy of this date with the day-of-year altered.

    Declaration

    Swift

    public func with(dayOfYear: Int) -> LocalDate

    Return Value

    An LocalDate based on this with the specified field set.

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

    • Results: An LocalDate based on this date with the specified amount added.

    Declaration

    Swift

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

    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 LocalDate with the specified period in years added.

    • Results: An LocalDate based on this date with the specified amount added.

    Declaration

    Swift

    public func plus(year: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified period in months added.

    • Results: An LocalDate based on this date with the specified amount added.

    Declaration

    Swift

    public func plus(month: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified period in weeks added.

    • Results: An LocalDate based on this date with the specified amount added.

    Declaration

    Swift

    public func plus(week: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified number of days added.

    • Results: An LocalDate based on this date with the specified amount added.

    Declaration

    Swift

    public func plus(day: Int) -> LocalDate
  • Returns a copy of this date with the specified amount subtracted.

    • Results: An LocalDate based on this date with the specified amount subtracted.

    Declaration

    Swift

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

    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 LocalDate with the specified period in years subtracted.

    • Results: An LocalDate based on this date with the specified amount subtracted.

    Declaration

    Swift

    public func minus(year: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified period in months subtracted.

    • Results: An LocalDate based on this date with the specified amount subtracted.

    Declaration

    Swift

    public func minus(month: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified period in weeks subtracted.

    • Results: An LocalDate based on this date with the specified amount subtracted.

    Declaration

    Swift

    public func minus(week: Int) -> LocalDate
  • Returns a copy of this LocalDate with the specified number of days subtracted.

    • Results: An LocalDate based on this date with the specified amount subtracted.

    Declaration

    Swift

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

    The start of one week is Monday.

    Declaration

    Swift

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

    Return Value

    The range of valid values for the field.

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

    Declaration

    Swift

    public func until(endDate: LocalDate) -> Period

    Parameters

    endDate

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

    Return Value

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

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

    Declaration

    Swift

    public func until(endDate: LocalDate, component: UntilComponent) -> Int64

    Parameters

    endDate

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

    component

    The unit to measure the amount in.

    Return Value

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

  • Formats this date 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: LocalDate, rhs: LocalDate) -> LocalDate
  • Undocumented

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public init(_ date: LocalDate)
  • Creates a local date from a month and day fields.

    Declaration

    Swift

    public init(month: Int, day: Int)
  • Creates a local date from the year, month and day fields.

    Declaration

    Swift

    public init(year: Int, month: Int, day: Int)
  • Creates a local date from a year and day-of-year fields.

    Declaration

    Swift

    public init(year: Int, dayOfYear: Int)
  • Creates a local date from the epoch day count fields.

    Declaration

    Swift

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