Skip to content

Commit

Permalink
proper NA handling in as.ITime.character, closes #2940
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Jun 17, 2018
1 parent d3ccd81 commit a471533
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#### BUG FIXES

1. `as.ITime.character` now properly handle NA when attempting to detect proper format from non-NA values in vector. Thanks @polyjian for reporting, closes [#2940](https://github.com/Rdatatable/data.table/issues/2940).

#### NOTES


Expand Down
2 changes: 1 addition & 1 deletion R/IDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ as.ITime.character <- function(x, format, ...) {
new <- strptime(x[w], format = f, ...)
nna <- !is.na(new)
if (any(nna)) {
y[ w[nna] ] <- new
y[ w[nna] ] <- new[nna]
w <- w[!nna]
}
}
Expand Down
3 changes: 3 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -11983,6 +11983,9 @@ test(1914.8, identical(dtGet(dt.comp, 1), dt[[1]]))
test(1914.9, identical(dtGet(dt.comp, 'b'), dt$b))
# END port of old testthat tests

# as.ITime.character bug for NA handling #2940
test(1915, as.ITime(c('xxx', '10:43')), structure(c(NA, 38580L), class = "ITime"))


###################################
# Add new tests above this line #
Expand Down

0 comments on commit a471533

Please sign in to comment.