Skip to content

Commit

Permalink
Added interval_to_period helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Jan 23, 2020
1 parent 4e33934 commit 98fc85a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ specials_prophet <- new_specials(
name = NULL){
# Extract data interval
interval <- tsibble::interval(self$data)
interval <- with(interval, lubridate::years(year) +
lubridate::period(3*quarter + month, units = "month") + lubridate::weeks(week) +
lubridate::days(day) + lubridate::hours(hour) + lubridate::minutes(minute) +
lubridate::seconds(second) + lubridate::milliseconds(millisecond) +
lubridate::microseconds(microsecond) + lubridate::nanoseconds(nanosecond))
interval <- interval_to_period(interval)

if(is.null(name) & is.character(period)){
name <- period
Expand Down
7 changes: 7 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interval_to_period <- function(interval){
with(interval, lubridate::years(year) +
lubridate::period(3*quarter + month, units = "month") + lubridate::weeks(week) +
lubridate::days(day) + lubridate::hours(hour) + lubridate::minutes(minute) +
lubridate::seconds(second) + lubridate::milliseconds(millisecond) +
lubridate::microseconds(microsecond) + lubridate::nanoseconds(nanosecond))
}

0 comments on commit 98fc85a

Please sign in to comment.