Skip to content

Commit

Permalink
as.IDate.POSIXct error fixed when tz= is explicitly passed. #977 #1498
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle committed Jun 5, 2017
1 parent fff0eb7 commit 6e0016d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions R/IDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ as.IDate.Date <- function(x, ...) {
structure(as.integer(x), class=c("IDate","Date"))
}

as.IDate.POSIXct <- function(x, ...) {
tz = attr(x, "tzone")
as.IDate.POSIXct <- function(x, tz = attr(x, "tzone"), ...) {
if (is.null(tz)) tz = "UTC"
as.IDate(as.Date(x, tz = tz, ...))
}
Expand Down
1 change: 1 addition & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -9101,6 +9101,7 @@ test(1689.1, capture.output(IDateTime(date_tz)), c(" idate itime", "1:
test(1689.2, as.IDate(date_tz), output="2016-01-13")
date_tz = structure(1496275200.11903, class = c("POSIXct", "POSIXt"), tzone = "America/Los_Angeles")
test(1689.3, as.character(as.IDate(date_tz)), "2017-05-31")
test(1689.4, as.character(as.IDate(date_tz, tz="UTC")), "2017-06-01")

# fix for #1766 and #1704
A = data.table(i = 1:6, j = rep(1:2, 3), x = letters[1:6], key = "i")
Expand Down

0 comments on commit 6e0016d

Please sign in to comment.