x <- year_day(2019)
# Set the day
set_day(x, 12:14)
# Set to the "last" day of the year
set_day(x, "last")
# Set to an invalid day of the year
invalid <- set_day(x, 366)
invalid
# Then resolve the invalid day by choosing the next valid day
invalid_resolve(invalid, invalid = "next")
# Cannot set a component two levels more precise than where you currently are
try(set_hour(x, 5))
Run the code above in your browser using DataLab