A plain_date() is a calendar date in the ISO 8601 calendar with no
time of day and no time zone, stored as an integer count of days since
1970-01-01. The constructor is Temporal.PlainDate and
Temporal.PlainDate.from() in one: it reads fields, strings or another
zutempo value.
Usage
plain_date(
year,
month = NULL,
day = NULL,
...,
month_code = NULL,
overflow = "constrain"
)
plain_date_compare(x, y)Arguments
- year
The year, or a string in ISO 8601 form (
"2026-01-31", a date-time whose time is ignored, or a year with a sign and six digits such as"+275760-09-13"), or aplain_date(),plain_date_time(),zoned_date_time(),Date,POSIXctorPOSIXltvalue to convert. A zoned orPOSIXtvalue gives its date in its own zone.- month, day
The month (1 to 12) and day of the month, when
yearis a number.monthmay be replaced bymonth_code.- ...
Must be empty.
- month_code
The month as
"M01"to"M12", instead ofmonth.- overflow
"constrain"(the default) clampsmonthanddayto their valid ranges,"reject"raises azutempo_range_errorfor them.- x, y
plain_date()values or strings, forplain_date_compare().
Details
Dates run from -271821-04-19 to +275760-09-13. A result outside that
range is a zutempo_range_error, never NA.
Members
Every member of Temporal.PlainDate in the pinned specification
(inst/spec/PINS) and the R function that implements it:
| Temporal | R |
new Temporal.PlainDate() | plain_date() |
Temporal.PlainDate.from() | plain_date() |
Temporal.PlainDate.compare() | plain_date_compare() |
.calendarId | calendar_id() |
.era | era() |
.eraYear | era_year() |
.year | year() |
.month | month() |
.monthCode | month_code() |
.day | day() |
.dayOfWeek | day_of_week() |
.dayOfYear | day_of_year() |
.weekOfYear | week_of_year() |
.yearOfWeek | year_of_week() |
.daysInWeek | days_in_week() |
.daysInMonth | days_in_month() |
.daysInYear | days_in_year() |
.monthsInYear | months_in_year() |
.inLeapYear | in_leap_year() |
.toPlainYearMonth() | temporal_to_plain_year_month() |
.toPlainMonthDay() | temporal_to_plain_month_day() |
.add() | temporal_add() |
.subtract() | temporal_subtract() |
.with() | temporal_with() |
.withCalendar() | temporal_with_calendar() |
.until() | temporal_until() |
.since() | temporal_since() |
.equals() | temporal_equals() |
.toPlainDateTime() | temporal_to_plain_date_time() |
.toZonedDateTime() | temporal_to_zoned_date_time() |
.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 |
Examples
plain_date("2026-01-31")
#> <zutempo_plain_date[1]>
#> [1] 2026-01-31
plain_date(2026, 2, 31)
#> <zutempo_plain_date[1]>
#> [1] 2026-02-28
plain_date(2026, month_code = "M02", day = 29, overflow = "constrain")
#> <zutempo_plain_date[1]>
#> [1] 2026-02-28
plain_date(c("2026-01-31", NA, "+275760-09-13"))
#> <zutempo_plain_date[3]>
#> [1] 2026-01-31 <NA> +275760-09-13
plain_date_compare(plain_date("2026-01-31"), "2026-02-01")
#> [1] -1