hadley/lubridate — Issue #105: Math on interval objects
Author: kenahoo
Created: 2012-01-05 19:32:06+00:00
State: open

If I'm given an interval object, I'd like to know how many days/hours/whatevers it represents between its start & stop. The only way I can see to do it currently is to use `difftime()` in a pretty awkward way:

> ival
[1] 2011-01-01 03:00:46 -- 2011-10-21 18:33:44
> class(ival)
[1] "interval" "numeric"

> difftime(attr(ival, "start") + as.numeric(ival), attr(ival, "start"), 'days')
Time difference of 293.6479 days

An `as.difftime.interval(x, units)` method would be helpful, interested in a patch? Or is there another way I'm not thinking of?