YearMonth

struct YearMonth
extension YearMonth : AutomationValue, Copyable, Decodable, Encodable, Equatable, Escapable, Hashable, Sendable, Sendable, StructDataRepresentable

Represents year and month.

This struct doesn’t include any time zone related information.

  • The year component.

    Declaration

    Swift

    let year: Int32
  • The month component.

    Declaration

    Swift

    let month: LocalDate.Month
  • Initializes the YearMonth with the year, month.

    Declaration

    Swift

    init(year: Int32, month: LocalDate.Month)
  • Initializes YearMonth with the trait decoder.

    Declaration

    Swift

    init(decoder: TraitDecoder) throws
  • Encodes YearMonth to the trait encoder.

    Declaration

    Swift

    func encode(with encoder: TraitEncoder) throws
  • Initializes a YearMonth by converting the given dateComponents.

    Throws

    when dateComponents have at least a nil year, month, or if they are not valid in the Gregorian calendar.

    Declaration

    Swift

    init(dateComponents: DateComponents) throws

    Parameters

    dateComponents

    The date components with the year, month to use.

  • The DateComponents representation of this year month.

    Declaration

    Swift

    var dateComponents: DateComponents { get }
  • Undocumented

    Declaration

    Swift

    enum StructFields
    extension YearMonth.StructFields : Equatable, Field, Hashable, RawRepresentable, Sendable
  • Returns the field corresponding to the given field ID.

    Declaration

    Swift

    static func structField(id: UInt32) -> (any Field)?
  • 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

    init(from decoder: any Decoder) throws