Convert between the plain types
Source:R/temporal.R, R/plain-date-time.R, R/plain-date.R, and 3 more
temporal_to_plain_date.RdTemporal's toPlainDate(), toPlainTime(), toPlainDateTime(),
toPlainYearMonth() and toPlainMonthDay(). A plain_year_month()
needs the day and a plain_month_day() the year to become a date;
both resolve it with overflow = "constrain", as Temporal does.
Usage
temporal_to_plain_date(x, ...)
# S3 method for class 'zutempo_plain_date_time'
temporal_to_plain_date(x, ...)
# S3 method for class 'zutempo_plain_date_time'
temporal_to_plain_time(x)
# S3 method for class 'zutempo_plain_date'
temporal_to_plain_date_time(x, time = NULL)
# S3 method for class 'zutempo_plain_date'
temporal_to_plain_year_month(x)
# S3 method for class 'zutempo_plain_date'
temporal_to_plain_month_day(x)
# S3 method for class 'zutempo_plain_month_day'
temporal_to_plain_date(x, year, ...)
# S3 method for class 'zutempo_plain_year_month'
temporal_to_plain_date(x, day, ...)
temporal_to_plain_time(x)
temporal_to_plain_date_time(x, time = NULL)
temporal_to_plain_year_month(x)
temporal_to_plain_month_day(x)
# S3 method for class 'zutempo_zoned_date_time'
temporal_to_plain_date_time(x, time = NULL)
# S3 method for class 'zutempo_zoned_date_time'
temporal_to_plain_date(x, ...)
# S3 method for class 'zutempo_zoned_date_time'
temporal_to_plain_time(x)Arguments
- x
A zutempo value.
- ...
Must be empty.
- time
For
temporal_to_plain_date_time()on aplain_date(): aplain_time(), a string aplain_time()reads, orNULLfor midnight.- year
The year that completes a
plain_month_day().- day
The day of the month that completes a
plain_year_month().
Value
A plain_date(), plain_time(), plain_date_time(),
plain_year_month() or plain_month_day().
Examples
x <- plain_date_time("2026-01-31T12:30:45")
temporal_to_plain_date(x)
#> <zutempo_plain_date[1]>
#> [1] 2026-01-31
temporal_to_plain_time(x)
#> <zutempo_plain_time[1]>
#> [1] 12:30:45
temporal_to_plain_date_time(plain_date("2026-01-31"), "08:00")
#> <zutempo_plain_date_time[1]>
#> [1] 2026-01-31T08:00:00
temporal_to_plain_year_month(plain_date("2026-01-31"))
#> <zutempo_plain_year_month[1]>
#> [1] 2026-01
temporal_to_plain_month_day(plain_date("2026-01-31"))
#> <zutempo_plain_month_day[1]>
#> [1] 01-31
temporal_to_plain_date(plain_year_month("2026-02"), day = 31)
#> <zutempo_plain_date[1]>
#> [1] 2026-02-28
temporal_to_plain_date(plain_month_day("02-29"), year = 2025)
#> <zutempo_plain_date[1]>
#> [1] 2025-02-28