I was wondering if as_date() could have a future argument that would cause only future dates to be created? Consider the dates of the upcoming NFL season, as an example. Here are the last few dates of the season, which are 2026 and 2027 dates.
[1] "December 27" "December 28" "December 31" "January 3" "January 4" "January 10"
If I perform as_date(format = "%B %d") on these dates, it creates the following results.
[1] "2026-12-27" "2026-12-28" "2026-12-31" "2026-01-03" "2026-01-04" "2026-01-10"
With the future argument, we could have as_date(format = "%B %d", future = TRUE) and produce this output.
[1] "2026-12-27" "2026-12-28" "2026-12-31" "2027-01-03" "2027-01-04" "2027-01-10"
Maybe even as_date() could be smart enough to detect any future rollover points from December to January in a list that was longer and multiyear and add more than just one year to the output dates when needed. My example only spans the crossover from 2026 to 2027, but a longer list may, perhaps, also contain a crossover from 2027 to 2028 at some point.
It is not too much trouble to correct this now, with
mutate(Date = case_when(Date < today() ~ Date %m+% years(1), .default = Date))
but code could be so much cleaner, and possibly faster, if as_date() had a future argument.
Thanks for creating and maintaining such wonderful tools, and considering this request. Have a great day!
I was wondering if
as_date()could have afutureargument that would cause only future dates to be created? Consider the dates of the upcoming NFL season, as an example. Here are the last few dates of the season, which are 2026 and 2027 dates.[1] "December 27" "December 28" "December 31" "January 3" "January 4" "January 10"If I perform
as_date(format = "%B %d")on these dates, it creates the following results.[1] "2026-12-27" "2026-12-28" "2026-12-31" "2026-01-03" "2026-01-04" "2026-01-10"With the
futureargument, we could haveas_date(format = "%B %d", future = TRUE)and produce this output.[1] "2026-12-27" "2026-12-28" "2026-12-31" "2027-01-03" "2027-01-04" "2027-01-10"Maybe even
as_date()could be smart enough to detect any future rollover points from December to January in a list that was longer and multiyear and add more than just one year to the output dates when needed. My example only spans the crossover from 2026 to 2027, but a longer list may, perhaps, also contain a crossover from 2027 to 2028 at some point.It is not too much trouble to correct this now, with
mutate(Date = case_when(Date < today() ~ Date %m+% years(1), .default = Date))but code could be so much cleaner, and possibly faster, if
as_date()had afutureargument.Thanks for creating and maintaining such wonderful tools, and considering this request. Have a great day!