Computes the day number corresponding to a given date (or vector of) from the first day of a start year. Typically, the start year should be the year of a STICS simulation start. Leap years are properly handled.
compute_day_from_date(
date,
start_year = NULL,
start_date = lifecycle::deprecated()
)
date(s) vector to be converted,
in the character format ("YYYY-MM-DD") or Date
format
year to be used as time reference (simulation start year). Optional.
numeric vector
date <- as.Date("2015-02-10")
compute_day_from_date(date = date)
#> [1] 41
compute_day_from_date(date = "2015-02-10", start_year = 2014)
#> [1] 406
date <- as.Date("2009-02-10")
compute_day_from_date(date = date, start_year = 2008 )
#> [1] 407
dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10"))
compute_day_from_date(date = dates, start_year = 2008 )
#> [1] 41 407