title: "Error: Invalid input: time_trans works with objects of class POSIXct only" with geom_rect and date/POSIXct types
body: <p>I have a dataset as follows:</p>
  
  <pre><code># A tibble: 30 x 4
  # Groups:   Group, Week_End_Date [30]
     Group Week_End_Date       time_period             Outcome
     &lt;lgl&gt;   &lt;dttm&gt;              &lt;fct&gt;                   &lt;dbl&gt;
   1 FALSE   2019-09-22 00:00:00 Baseline                5241.
   2 FALSE   2019-09-29 00:00:00 Baseline                5089.
   3 FALSE   2019-10-06 00:00:00 Baseline                4991.
   4 FALSE   2019-10-13 00:00:00 Baseline                4920.
   5 FALSE   2019-10-20 00:00:00 Baseline                4896.
   6 FALSE   2019-10-27 00:00:00 Baseline                4921.
   7 FALSE   2019-11-03 00:00:00 Baseline                4999.
   8 FALSE   2019-11-10 00:00:00 Activation              5003.
   9 FALSE   2019-11-17 00:00:00 Activation              4995.
  10 FALSE   2019-11-24 00:00:00 Activation              5098.
  # ... with 20 more rows
  </code></pre>
  
  <p>I can plot a graph e.g.</p>
  
  <pre><code>    ggplot(dataset, aes(y=Outcome, x=Week_End_Date, color=Group, fill=Group)) +
        geom_point() +
        geom_line() +
        theme_bw() +
  labs(y="Outcome", x="Date", color="Group", fill="Group")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jvdLi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jvdLi.png" alt="graph without rectangle"></a></p>
  
  <p>I want to shade this based on the variable "time_period" (Week_End_Date is nested within this)</p>
  
  <p>e.g.</p>
  
  <pre><code>ggplot(dataset, aes(y=Outcome, x=Week_End_Date, color=Group, fill=Group)) +
    geom_point() +
    geom_line() +
    theme_bw()
    geom_line() +
    theme_bw() +
   geom_rect(aes(fill=time_period, xmax=Inf, xmin=-Inf, ymax=Inf, ymin=-Inf)) 
  </code></pre>
  
  <p>however this results in the error message</p>
  
  <pre><code>Error: Invalid input: time_trans works with objects of class POSIXct only
  </code></pre>
  
  <p>I also tried drawing the two rectangles separately (I will add the alpha argument later once they plot successfully):</p>
  
  <pre><code>    ggplot(dataset, aes(y=Outcome, x=Week_End_Date, color=Group, fill=Group)) +
        geom_point() +
        geom_line() +
        theme_bw()
        geom_line() +
        theme_bw() +
  geom_rect(inherit.aes=FALSE, aes(xmin=dmy("06Nov2019"), xmax=dmy("06Jan2020"), ymax=Inf, ymin=-Inf), fill="red") +
    geom_rect(inherit.aes=FALSE, aes(xmin=dmy("01Jan2019"), xmax=dmy("06Nov2019"), ymax=Inf, ymin=-Inf), fill="blue") 
  </code></pre>
  
  <p>but this results in the same error.</p>
  
  <p>Can anyone advise me on what I'm doing wrong? I feel like this should be far more straightforward than it seems! The x variable is a datetime</p>