Convert a character or date class to decimal, taking into account leap years.

dec.date(date)

Arguments

date

Either a Date class object or an unambiguous character string in the format "YYYY-MM-DD".

Value

Numeric expression of the date, year plus the fraction of the year passed as of the date.

Details

This makes use of the lubridate::decimal_date to compute the proportion of the year that has passed. If the date is numeric, it is returned as such. If it is "character", we try to coerce to date through lubridate::ymd, ergo, it is best to specify a character string in an unambiguous "YYYY-MM-DD" format. If date is given in a "Date" class it is dealt with accordingly.