To create difftime object
with additional time units 'months'
and 'years'
.
asDifftime(
tim,
units = names(timeUnits()),
negative_do = stop(sQuote(deparse1(substitute(tim))), " has negative value!"),
...
)
Function asDifftime returns a difftime object.
numeric or difftime object, similar usage as in function as.difftime
character scalar,
similar usage as in function as.difftime,
but with additional options 'months'
and 'years'
exception handling
if input tim
has negative element(s).
Default is to stop
additional parameters, currently not in use
Function asDifftime improves function as.difftime in terms that
If input tim
is a difftime object,
function units_difftime<- is called and the unit of tim
is updated.
In function as.difftime, tim
is returned directly, i.e., parameter units
is ignored
Time units 'months'
and 'years'
are supported,
in addition to 'secs'
, 'mins'
, 'hours'
, 'days'
, 'weeks'
supported in function as.difftime.
Moreover, partial matching (via function match.arg) is allowed,
while function as.difftime requires exact matching.
End user may choose to stop if tim
has negative values.
Function as.difftime does not check for negative tim
.