A plain_year_month() is a month of a year in the ISO 8601 calendar,
stored as an integer count of months since January 1970.
The constructor is Temporal.PlainYearMonth and
Temporal.PlainYearMonth.from() in one: it reads fields, strings or a
plain_date() or plain_date_time().
Usage
plain_year_month(
year,
month = NULL,
...,
month_code = NULL,
overflow = "constrain"
)
plain_year_month_compare(x, y)Arguments
- year
The year, or a string in ISO 8601 form (
"2026-03","202603", or a full date or date-time whose day and time are ignored), or aplain_year_month(),plain_date()orplain_date_time()to convert.- month
The month (1 to 12), when
yearis a number. May be replaced bymonth_code.- ...
Must be empty.
- month_code
The month as
"M01"to"M12", instead ofmonth.- overflow
"constrain"(the default) clampsmonthto 1 to 12,"reject"raises azutempo_range_error.- x, y
plain_year_month()values or strings, forplain_year_month_compare().
Value
A plain_year_month() vector; plain_year_month_compare()
returns an integer vector of -1, 0 and 1.
Details
Months run from -271821-04 to +275760-09, every month that holds a
representable plain_date().
Members
Every member of Temporal.PlainYearMonth in the pinned specification
(inst/spec/PINS) and the R function that implements it:
| Temporal | R |
new Temporal.PlainYearMonth() | plain_year_month() |
Temporal.PlainYearMonth.from() | plain_year_month() |
Temporal.PlainYearMonth.compare() | plain_year_month_compare() |
.calendarId | calendar_id() |
.era | era() |
.eraYear | era_year() |
.year | year() |
.month | month() |
.monthCode | month_code() |
.daysInYear | days_in_year() |
.daysInMonth | days_in_month() |
.monthsInYear | months_in_year() |
.inLeapYear | in_leap_year() |
.with() | temporal_with() |
.add() | temporal_add() |
.subtract() | temporal_subtract() |
.until() | temporal_until() |
.since() | temporal_since() |
.equals() | temporal_equals() |
.toString() | temporal_to_string() |
.toLocaleString() | none: ECMA-402 (locale formatting) is out of scope |
.toJSON() | none: format() covers it |
.valueOf() | none: throws in JavaScript; no R counterpart |
.toPlainDate() | temporal_to_plain_date() |
Examples
plain_year_month("2026-03")
#> <zutempo_plain_year_month[1]>
#> [1] 2026-03
plain_year_month(2026, 3)
#> <zutempo_plain_year_month[1]>
#> [1] 2026-03
plain_year_month(plain_date("2026-03-15"))
#> <zutempo_plain_year_month[1]>
#> [1] 2026-03
temporal_to_plain_date(plain_year_month("2026-02"), day = 31)
#> <zutempo_plain_date[1]>
#> [1] 2026-02-28
plain_year_month_compare("2026-02", "2026-03")
#> [1] -1