Skip to content

Commit

Permalink
[187773038]: add resolution for datetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
gergness committed Jun 14, 2024
1 parent 538554d commit fadb739
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/variable-update.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
if (any(missings)) {
x$column <- as.list(x$column)
x$column[missings] <- rep(
list(.no.data.value(type(variable))), sum(missings)
list(.no.data.value(variable)), sum(missings)
)
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ setMethod(
function(x, i, j, value) {
if (all(is.na(value))) {
## For assigning NA
value <- .no.data.value(type(x), add.type = TRUE)
value <- .no.data.value(x, add.type = TRUE)
if (has.categories(x)) {
return(.categorical.update[["numeric"]](x, i, j, value))
}
Expand All @@ -267,12 +267,14 @@ setMethod(
)

.no.data.value <- function(x, add.type = FALSE) {
if (has.categories(x)) {
x_type <- type(x)
if (has.categories(x_type)) {
return(NA)
} else {
out <- NA
if (add.type) {
out <- list(value = NA, type = list(class = x))
out <- list(value = NA, type = list(class = x_type))
if (type == "datetime") out$resolution <- resolution(x)
}
return(out)
}
Expand Down

0 comments on commit fadb739

Please sign in to comment.