diff --git a/NEWS.md b/NEWS.md index f78eca84..02c7928f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,6 +17,7 @@ Version 1.6.0.9000 * [#486](https://github.com/hadley/lubridate/issues/486) ceiling_date handles `NA` properly. * [#483](https://github.com/hadley/lubridate/pull/483) Fix add_duration_to_date error when duration first element is NA. * [#524](https://github.com/hadley/lubridate/pull/524) Correctly compute length of period in months (issue #490) +* [#525](https://github.com/hadley/lubridate/pull/525) Fix to prevent `day<-`, `minute<-`, etc. from producing an error when length(x) is 0 (issue #517) Version 1.6.0 ============= diff --git a/R/periods.r b/R/periods.r index 219729df..d063848b 100644 --- a/R/periods.r +++ b/R/periods.r @@ -401,6 +401,8 @@ parse_period <- function(x){ month = 0, year = 0 ) + if (nrow(pieces) == 0) defaults <- defaults[0, ] + pieces <- cbind(pieces, defaults[setdiff(names(defaults), names(pieces))]) ## pieces <- pieces[c("year", "month", "week", "day", "hour", "minute", "second")]