Skip to content

fix #495#500

Merged
yihui merged 2 commits intorstudio:masterfrom
shrektan:fix495
Feb 13, 2018
Merged

fix #495#500
yihui merged 2 commits intorstudio:masterfrom
shrektan:fix495

Conversation

@shrektan
Copy link
Collaborator

@shrektan shrektan commented Feb 10, 2018

styleInterval() and styleEqual() now generates the correct callback for Date and Datetime values.

Closes #495

Example

library(DT)
dates <- as.Date(c("2018-01-01","2019-01-01"))
times <- as.POSIXct(c("2018-01-01 15:00", "2018-01-01 20:00"), tz = "UTC")
tbl <- 
  data.frame(
    Date = dates,
    Date2 = dates,
    Time = times,
    Time2 = times,
    Time3 = times,
    Time4 = times
  )
tbl %>%
  datatable() %>%
  formatStyle(columns = c("Date", "Date2"),
              backgroundColor = styleInterval(as.Date("2018-02-02"), c("#FB717E", "#89EC6A"))) %>%
  formatStyle(columns = c("Time", "Time2"),
              backgroundColor = styleInterval(as.POSIXct(c("2018-01-01 18:00"), tz = "UTC"), c("#FB717E", "#89EC6A"))) %>%
  formatStyle(columns = c("Time3"),
              backgroundColor = styleInterval(as.POSIXct(c("2018-01-02 02:00"), tz = "PRC"), c("#FB717E", "#89EC6A"))) %>%
  formatStyle(columns = c("Time4"),
              backgroundColor = styleEqual(times, c("#FB717E", "#89EC6A"))) %>%
  formatDate(columns = c("Date2", "Time2"), c("toDateString", "toTimeString"))

@shrektan shrektan changed the title fix #498 fix #495 Feb 10, 2018
Copy link
Contributor

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thanks!

@yihui yihui added this to the v0.5 milestone Feb 13, 2018
@yihui yihui merged commit e47d15f into rstudio:master Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants