@@ -207,3 +207,68 @@ get_offset.default <- function(x, ...) {
207207get_offset.grates_period <- function (x , ... ) {
208208 attr(x , " offset" )
209209}
210+
211+ # -------------------------------------------------------------------------
212+ # ' @name grouped_date_accessors
213+ # ' @export
214+ get_interval_duration <- function (x , ... ) {
215+ UseMethod(" get_interval_duration" )
216+ }
217+
218+ # -------------------------------------------------------------------------
219+ # ' @rdname grouped_date_accessors
220+ # ' @export
221+ get_interval_duration.default <- function (x , ... ) {
222+ stopf(" Not implemented for class [%s]." , toString(class(x )))
223+ }
224+
225+ # -------------------------------------------------------------------------
226+ # ' @rdname grouped_date_accessors
227+ # ' @export
228+ get_interval_duration.grates_yearweek <- function (x , ... ) {
229+ rep(7 , length(x ))
230+ }
231+
232+ # -------------------------------------------------------------------------
233+ # ' @rdname grouped_date_accessors
234+ # ' @export
235+ get_interval_duration.grates_int_period <- function (x , ... ) {
236+ rep(attr(x , " n" ), length(x ))
237+ }
238+
239+ # -------------------------------------------------------------------------
240+ # ' @rdname grouped_date_accessors
241+ # ' @export
242+ get_interval_duration.grates_isoweek <- get_interval_duration.grates_yearweek
243+
244+ # -------------------------------------------------------------------------
245+ # ' @rdname grouped_date_accessors
246+ # ' @export
247+ get_interval_duration.grates_epiweek <- get_interval_duration.grates_yearweek
248+
249+ # -------------------------------------------------------------------------
250+ # ' @rdname grouped_date_accessors
251+ # ' @export
252+ get_interval_duration.grates_yearmonth <- function (x , ... ) {
253+ as.double(as.Date(x + 1 ) - as.Date(x ), units = " days" )
254+ }
255+
256+ # -------------------------------------------------------------------------
257+ # ' @rdname grouped_date_accessors
258+ # ' @export
259+ get_interval_duration.grates_month <- get_interval_duration.grates_yearmonth
260+
261+ # -------------------------------------------------------------------------
262+ # ' @rdname grouped_date_accessors
263+ # ' @export
264+ get_interval_duration.grates_yearquarter <- get_interval_duration.grates_yearmonth
265+
266+ # -------------------------------------------------------------------------
267+ # ' @rdname grouped_date_accessors
268+ # ' @export
269+ get_interval_duration.grates_year <- get_interval_duration.grates_yearmonth
270+
271+ # -------------------------------------------------------------------------
272+ # ' @rdname grouped_date_accessors
273+ # ' @export
274+ get_interval_duration.grates_period <- get_interval_duration.grates_int_period
0 commit comments