struct YearMonthextension YearMonth : AutomationValue, Comparable, Copyable, Copyable, Decodable, Encodable, Equatable, Equatable, Equatable, Escapable, Escapable, Hashable, Hashable, Sendable, Sendable, StructDataRepresentableRepresents 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
YearMonthwith the year, month.Declaration
Swift
init(year: Int32, month: LocalDate.Month) -
Initializes
YearMonthwith the trait decoder.Declaration
Swift
init(decoder: TraitDecoder) throws -
Encodes
YearMonthto the trait encoder.Declaration
Swift
func encode(with encoder: TraitEncoder) throws -
Initializes a
YearMonthby converting the givendateComponents.Throws
whendateComponentshave at least anilyear,month, or if they are not valid in the Gregorian calendar.Declaration
Swift
init(dateComponents: DateComponents) throws -
The
DateComponentsrepresentation of this year month.Declaration
Swift
var dateComponents: DateComponents { get } -
Returns the field corresponding to the given field ID.
Declaration
Swift
static func structField(id: UInt32) -> (any Field)? -
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
This function is the only requirement of the
Comparableprotocol. The remainder of the relational operator functions are implemented by the standard library for any type that conforms toComparable.Declaration
Swift
static func < (lhs: YearMonth, rhs: YearMonth) -> BoolParameters
lhsA value to compare.
rhsAnother value to compare.
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Declaration
Swift
static func == (lhs: YearMonth, rhs: YearMonth) -> BoolParameters
lhsA value to compare.
rhsAnother value to compare.
-
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