Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,17 @@ S3method(as.POSIXct, IDate)
S3method(as.POSIXct, ITime)
S3method(as.POSIXlt, ITime)
S3method(c, IDate)
S3method(cut, IDate)
S3method(c, ITime)
S3method(format, ITime)
S3method(IDateTime, default)
S3method(mean, IDate)
S3method(mean, ITime)
S3method(print, ITime)
S3method(rep, IDate)
S3method(rep, ITime)
S3method(round, IDate)
S3method(seq, IDate)
S3method(split, IDate)
S3method(seq, ITime)
S3method(unique, IDate)
S3method(unique, ITime)
S3method('[<-', IDate)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@

19. `merge.data,table` now retains any custom classes of the first argument, [#1378](https://github.com/Rdatatable/data.table/issues/1378). Thanks to @michaelquinn32 for reopening.

20. `c`, `seq` and `mean` of `ITime` objects now retain the `ITime` class via new `ITime` methods, [#3628](https://github.com/Rdatatable/data.table/issues/3628). Thanks @UweBlock for reporting. The `cut` and `split` methods for `ITime` have been removed since the default methods work, [#3630](https://github.com/Rdatatable/data.table/pull/3630).

#### NOTES

1. `rbindlist`'s `use.names="check"` now emits its message for automatic column names (`"V[0-9]+"`) too, [#3484](https://github.com/Rdatatable/data.table/pull/3484). See news item 5 of v1.12.2 below.
Expand Down
6 changes: 4 additions & 2 deletions R/IDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ as.Date.IDate = function(x, ...) {
}

mean.IDate =
cut.IDate =
seq.IDate =
c.IDate =
rep.IDate =
split.IDate =
unique.IDate =
function(x, ...) {
as.IDate(NextMethod())
Expand Down Expand Up @@ -258,6 +256,10 @@ unique.ITime = function(x, ...) {
ans
}

# various methods to ensure ITime class is retained, #3628
mean.ITime = seq.ITime = c.ITime = function(x, ...) as.ITime(NextMethod())


# create a data.table with IDate and ITime columns
# should work for most date/time formats like POSIXct

Expand Down
4 changes: 4 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -14977,6 +14977,10 @@ DT = data.table(
test(2054, DT[order(C)[1:5], B, verbose=TRUE], c('b', 'b', 'c', 'c', 'a'),
output = 'order optimisation is on')

# ITime class should be retained for same methods as IDate, #3628
test(2055.1, seq(from = as.ITime('00:00:00'), to = as.ITime('00:00:05'), by = 5L), as.ITime(c(0, 5L)))
test(2055.2, c(as.ITime(0L), as.ITime(1L)), as.ITime(c(0L, 1L)))
test(2055.3, mean(as.ITime(c(0L, 0L))), as.ITime(0L))

###################################
# Add new tests above this line #
Expand Down
5 changes: 3 additions & 2 deletions man/IDateTime.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
\alias{as.POSIXct.ITime}
\alias{as.POSIXlt.ITime}
\alias{c.IDate}
\alias{cut.IDate}
\alias{c.ITime}
\alias{format.ITime}
\alias{IDateTime.default}
\alias{mean.IDate}
\alias{mean.ITime}
\alias{print.ITime}
\alias{rep.IDate}
\alias{rep.ITime}
\alias{round.IDate}
\alias{seq.IDate}
\alias{split.IDate}
\alias{seq.ITime}
\alias{second}
\alias{minute}
\alias{hour}
Expand Down