Skip to content

Commit

Permalink
mention POSIXct in error messages when using POSIXlt.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed May 28, 2019
1 parent d1b3bf5 commit e08aee1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/mutate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ConstantRecycler {

inline SEXP constant_recycle(SEXP x, int n, const SymbolString& name) {
if (Rf_inherits(x, "POSIXlt")) {
bad_col(name, "is of unsupported class POSIXlt");
bad_col(name, "is of unsupported class POSIXlt; please use POSIXct instead");
}
switch (TYPEOF(x)) {
case INTSXP:
Expand Down Expand Up @@ -160,7 +160,7 @@ class MutateCallProxy {
Rcpp::RObject first(get(indices));

if (Rf_inherits(first, "POSIXlt")) {
bad_col(name, "is of unsupported class POSIXlt");
bad_col(name, "is of unsupported class POSIXlt; please use POSIXct instead");
}

if (Rf_inherits(first, "data.frame")) {
Expand Down Expand Up @@ -220,7 +220,7 @@ SEXP MutateCallProxy<NaturalDataFrame>::evaluate() {
if (Rf_isNull(first)) return R_NilValue;

if (Rf_inherits(first, "POSIXlt")) {
bad_col(name, "is of unsupported class POSIXlt");
bad_col(name, "is of unsupported class POSIXlt; please use POSIXct instead");
}

if (Rf_inherits(first, "data.frame")) {
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-mutate.r
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ test_that("mutate fails on unsupported column type", {
df <- data.frame(created = c("2014/1/1", "2014/1/2", "2014/1/2"))
expect_error(
mutate(df, date = strptime(created, "%Y/%m/%d")),
"Column `date` is of unsupported class POSIXlt",
"Column `date` is of unsupported class POSIXlt; please use POSIXct instead",
fixed = TRUE
)

Expand All @@ -220,7 +220,7 @@ test_that("mutate fails on unsupported column type", {
)
expect_error(
mutate(group_by(df, g), date = strptime(created, "%Y/%m/%d")),
"Column `date` is of unsupported class POSIXlt",
"Column `date` is of unsupported class POSIXlt; please use POSIXct instead",
fixed = TRUE
)
})
Expand Down Expand Up @@ -442,15 +442,15 @@ test_that("mutate forbids POSIXlt results (#670)", {
expect_error(
data.frame(time = "2014/01/01 10:10:10") %>%
mutate(time = as.POSIXlt(time)),
"Column `time` is of unsupported class POSIXlt",
"Column `time` is of unsupported class POSIXlt; please use POSIXct instead",
fixed = TRUE
)

expect_error(
data.frame(time = "2014/01/01 10:10:10", a = 2) %>%
group_by(a) %>%
mutate(time = as.POSIXlt(time)),
"Column `time` is of unsupported class POSIXlt",
"Column `time` is of unsupported class POSIXlt; please use POSIXct instead",
fixed = TRUE
)
})
Expand Down

0 comments on commit e08aee1

Please sign in to comment.