Skip to content

Commit

Permalink
Merge pull request #198 from r-dbi/b-roundtrip-time
Browse files Browse the repository at this point in the history
- `"roundtrip_timestamp"` tests now accept a time zone set by the database backend (#198).
  • Loading branch information
krlmlr committed Oct 26, 2020
2 parents d095528 + 0f8eb42 commit 8c99358
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions R/spec-sql-append-table.R
Expand Up @@ -343,7 +343,7 @@ spec_sql_append_table <- list(
86400 * 90, 86400 * 180, 86400 * 270,
1e9, 5e9
)
attr(local, "tzone") <- NULL
attr(local, "tzone") <- ""
tbl_in <- data.frame(id = seq_along(local))
tbl_in$local <- local
tbl_in$GMT <- lubridate::with_tz(local, tzone = "GMT")
Expand All @@ -357,8 +357,9 @@ spec_sql_append_table <- list(
con, tbl_in,
transform = function(out) {
dates <- vapply(out, inherits, "POSIXt", FUN.VALUE = logical(1L))
zoned <- dates & (names(out) != "local")
out[zoned] <- Map(lubridate::with_tz, out[zoned], names(out)[zoned])
tz <- names(out)
tz[tz == "local"] <- ""
out[dates] <- Map(lubridate::with_tz, out[dates], tz[dates])
out
}
)
Expand Down
7 changes: 4 additions & 3 deletions R/spec-sql-write-table.R
Expand Up @@ -483,7 +483,7 @@ spec_sql_write_table <- list(
86400 * 90, 86400 * 180, 86400 * 270,
1e9, 5e9
)
attr(local, "tzone") <- NULL
attr(local, "tzone") <- ""
tbl_in <- data.frame(id = seq_along(local))
tbl_in$local <- local
tbl_in$GMT <- lubridate::with_tz(local, tzone = "GMT")
Expand All @@ -496,8 +496,9 @@ spec_sql_write_table <- list(
con, tbl_in,
transform = function(out) {
dates <- vapply(out, inherits, "POSIXt", FUN.VALUE = logical(1L))
zoned <- dates & (names(out) != "local")
out[zoned] <- Map(lubridate::with_tz, out[zoned], names(out)[zoned])
tz <- names(out)
tz[tz == "local"] <- ""
out[dates] <- Map(lubridate::with_tz, out[dates], tz[dates])
out
}
)
Expand Down

0 comments on commit 8c99358

Please sign in to comment.