Skip to contents

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 a plain_date(), plain_date_time(), zoned_date_time(), Date, POSIXct or POSIXlt value to convert. A zoned or POSIXt value gives its date in its own zone.

month, day

The month (1 to 12) and day of the month, when year is a number. month may be replaced by month_code.

...

Must be empty.

month_code

The month as "M01" to "M12", instead of month.

overflow

"constrain" (the default) clamps month and day to their valid ranges, "reject" raises a zutempo_range_error for them.

x, y

plain_date() values or strings, for plain_date_compare().

Value

A plain_date() vector; plain_date_compare() returns an integer vector of -1, 0 and 1.

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:

TemporalR
new Temporal.PlainDate()plain_date()
Temporal.PlainDate.from()plain_date()
Temporal.PlainDate.compare()plain_date_compare()
.calendarIdcalendar_id()
.eraera()
.eraYearera_year()
.yearyear()
.monthmonth()
.monthCodemonth_code()
.dayday()
.dayOfWeekday_of_week()
.dayOfYearday_of_year()
.weekOfYearweek_of_year()
.yearOfWeekyear_of_week()
.daysInWeekdays_in_week()
.daysInMonthdays_in_month()
.daysInYeardays_in_year()
.monthsInYearmonths_in_year()
.inLeapYearin_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