Skip to contents

Temporal'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 a plain_date(): a plain_time(), a string a plain_time() reads, or NULL for midnight.

year

The year that completes a plain_month_day().

day

The day of the month that completes a plain_year_month().

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