struct YearMonth
extension YearMonth : AutomationValue, Comparable, Copyable, Copyable, Decodable, Encodable, Equatable, Equatable, Equatable, Escapable, Escapable, Hashable, 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 givendateComponents
.Throws
whendateComponents
have at least anil
year
,month
, or if they are not valid in the Gregorian calendar.Declaration
Swift
init(dateComponents: DateComponents) throws
-
The
DateComponents
representation 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
Comparable
protocol. 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) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Swift
static func == (lhs: YearMonth, rhs: YearMonth) -> Bool
Parameters
lhs
A value to compare.
rhs
Another 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