Skip to content

Commit c767771

Browse files
always copy_names() in as.IDate for POSIXct
1 parent 417989b commit c767771

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
14. Subtracting an `IDate` from a `Date` is fast again by avoiding unnecessary conversion to `POSIXlt`/`POSIXct`, [#7825](https://github.com/Rdatatable/data.table/issues/7825). Thanks @gilesheywood for the report and @ben-schwen for the fix.
7070

71-
15. `as.IDate()` and `as.ITime()` now preserve names, matching base `as.Date()` behavior, [#7252](https://github.com/Rdatatable/data.table/issues/7252). Thanks @DavisVaughan for the report and @venom1204 for the PR.
71+
15. `as.IDate()` and `as.ITime()` now preserve names, matching base `as.Date()` behavior, [#7252](https://github.com/Rdatatable/data.table/issues/7252). Thanks @DavisVaughan for the report, @venom1204 for the PR, and @MichaelChirico for patching the fix back to old versions of R.
7272

7373
16. `copy()` is now more consistent about reallocating nested `data.table`s, [#7456](https://github.com/Rdatatable/data.table/issues/7456). The resulting list is now only overwritten when necessary, list columns inside data.tables are searched recursively, and their attributes are walked in search of data.tables to reallocate as well. Thanks to @be-marc for the report, @david-cortes for additional information, and @aitap for the fix.
7474

R/IDateTime.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ as.IDate.POSIXct = function(x, tz = attr(x, "tzone", exact=TRUE), ...) {
4747
if (is_utc(tz)) {
4848
ans = as.integer(as.numeric(x) %/% 86400L) # %/% returns a new object, so setattr() is safe
4949
setattr(ans, "class", c("IDate", "Date"))
50-
copy_names(ans, names(x))
5150
} else {
52-
as.IDate(as.Date(x, tz = tz %||% '', ...))
51+
ans = as.IDate(as.Date(x, tz = tz %||% '', ...))
5352
}
53+
copy_names(ans, names(x))
5454
}
5555

5656
as.IDate.IDate = function(x, ...) x

0 commit comments

Comments
 (0)