Calendar dates with clock times: Temporal's PlainDateTime
Source:R/plain-date-time.R
plain_date_time.RdA plain_date_time() is a calendar date in the ISO 8601 calendar with a
time of day to the nanosecond and no time zone, stored as a complex
vector whose real part is the epoch day and whose imaginary part is the
nanoseconds of day. The constructor is
Temporal.PlainDateTime and Temporal.PlainDateTime.from() in one: it
reads fields, strings or another zutempo value.
Usage
plain_date_time(
year,
month = NULL,
day = NULL,
hour = 0,
minute = 0,
second = 0,
millisecond = 0,
microsecond = 0,
nanosecond = 0,
...,
month_code = NULL,
overflow = "constrain"
)
plain_date_time_compare(x, y)Arguments
- year
The year, or a string in ISO 8601 form (
"2026-01-31T12:30:45.5", a date alone for midnight, an offset is ignored andZis rejected), or aplain_date_time(),plain_date()(for midnight),zoned_date_time(),Date(for midnight),POSIXctorPOSIXltvalue to convert. A zoned orPOSIXtvalue gives its wall-clock time 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.- hour, minute, second, millisecond, microsecond, nanosecond
The time fields, 0 by default.
- ...
Must be empty.
- month_code
The month as
"M01"to"M12", instead ofmonth.- overflow
"constrain"(the default) clamps each field to its range,"reject"raises azutempo_range_error.- x, y
plain_date_time()values or strings, forplain_date_time_compare().
Value
A plain_date_time() vector; plain_date_time_compare()
returns an integer vector of -1, 0 and 1.
Details
Values may lie up to a day beyond the range of a plain_date(), from
just after -271821-04-19T00:00 to the end of +275760-09-13. A result
outside that range is a zutempo_range_error, never NA.
Members
Every member of Temporal.PlainDateTime in the pinned specification
(inst/spec/PINS) and the R function that implements it:
| Temporal | R |
new Temporal.PlainDateTime() | plain_date_time() |
Temporal.PlainDateTime.from() | plain_date_time() |
Temporal.PlainDateTime.compare() | plain_date_time_compare() |
.calendarId | calendar_id() |
.era | era() |
.eraYear | era_year() |
.year | year() |
.month | month() |
.monthCode | month_code() |
.day | day() |
.hour | hour() |
.minute | minute() |
.second | second() |
.millisecond | millisecond() |
.microsecond | microsecond() |
.nanosecond | nanosecond() |
.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() |
.with() | temporal_with() |
.withPlainTime() | temporal_with_plain_time() |
.withCalendar() | temporal_with_calendar() |
.add() | temporal_add() |
.subtract() | temporal_subtract() |
.until() | temporal_until() |
.since() | temporal_since() |
.round() | temporal_round() |
.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 |
.toZonedDateTime() | temporal_to_zoned_date_time() |
.toPlainDate() | temporal_to_plain_date() |
.toPlainTime() | temporal_to_plain_time() |
Examples
plain_date_time("2026-01-31T12:30:45.5")
#> <zutempo_plain_date_time[1]>
#> [1] 2026-01-31T12:30:45.5
plain_date_time(2026, 1, 31, 12, 30)
#> <zutempo_plain_date_time[1]>
#> [1] 2026-01-31T12:30:00
plain_date_time(plain_date("2026-01-31"))
#> <zutempo_plain_date_time[1]>
#> [1] 2026-01-31T00:00:00
plain_date_time_compare("2026-01-31T12:30", "2026-01-31T12:31")
#> [1] -1