Skip to content

as.Date.numeric origin default

1 message · Tony Plate

#
Seems like it makes sense to have a default origin of 1970-01-01 for 
as.Date.numeric().  Are there any strong arguments for requiring users 
to specify the origin for every invocation of as.Date.numeric()?

The code could be:

as.Date.numeric <- function(x, origin="1970-01-01", ...)
{
    if ((missing(origin) && nargs()==1)
        || (is.character(origin) && origin=="1970-01-01" && nargs()==2))
        return(structure(as.integer(x), class="Date"))
    as.Date(origin, ...) + as.integer(x)
}

I guess the use of as.integer(x) is debatable, but using it seems 
consistent with the "Details" section of ?Date.

-- Tony Plate
Jeff Ryan wrote: