Skip to content

Commit 8606347

Browse files
committed
Fixes tidyverse#3533 - helpful error msg on date vs datetime scale
1 parent c1b6275 commit 8606347

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

R/scale-date.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ ScaleContinuousDatetime <- ggproto("ScaleContinuousDatetime", ScaleContinuous,
369369
i = "The value was converted to {obj_type_friendly(x)}."
370370
), call = self$call)
371371
}
372+
if (inherits(x, "Date")) {
373+
cli::cli_abort("You supplied a {.cls {class(x)}} field.
374+
Did you mean to use {.fn scale_*_date}?", call = self$call)
375+
}
372376
ggproto_parent(ScaleContinuous, self)$transform(x)
373377
},
374378
map = function(self, x, limits = self$get_limits()) {
@@ -416,6 +420,10 @@ ScaleContinuousDate <- ggproto("ScaleContinuousDate", ScaleContinuous,
416420
i = "The value was converted to {obj_type_friendly(x)}."
417421
), call = self$call)
418422
}
423+
if (inherits(x, "POSIXct")) {
424+
cli::cli_abort("You supplied a {.cls {class(x)}} field.
425+
Did you mean to use {.fn scale_*_datetime}?", call = self$call)
426+
}
419427
ggproto_parent(ScaleContinuous, self)$transform(x)
420428
},
421429
get_breaks = function(self, limits = self$get_limits()) {

0 commit comments

Comments
 (0)