Consider the following example
require(data.table)
wd <- structure(list(Year = c(2006L, 2006L, 2006L), day = c(361L, 361L,
360L), hour = c(14L, 8L, 8L), mint = c(30L, 0L, 30L), valu1 = c(0.5,
0.3, 0.4), Date = structure(c(1167229800, 1167206400, 1167121800
), class = c("POSIXct", "POSIXt"), tzone = "UTC")), .Names = c("Year",
"day", "hour", "mint", "valu1", "Date"), row.names = c(NA, -3L
), class = "data.frame") ## "UTC" time zone
setDT(wd)[, `:=`(start = Date - 1800L, end = Date + 1800L)]
# Year day hour mint valu1 Date start end
#1: 2006 361 14 30 0.5 2006-12-27 14:30:00 2006-12-27 14:00:00 2006-12-27 15:00:00
#2: 2006 361 8 0 0.3 2006-12-27 08:00:00 2006-12-27 07:30:00 2006-12-27 08:30:00
#3: 2006 360 8 30 0.4 2006-12-26 08:30:00 2006-12-26 08:00:00 2006-12-26 09:00:00
tt <- as.POSIXct(c("2006/12/27 14:23:59", "2006/12/27 16:47:59", "2006/12/27 19:12:00"),
format = "%Y/%m/%d %T", tz = "Asia/Jerusalem") ## different time zone
wg <- data.table(start = tt, end = tt)
# start end
#1: 2006-12-27 14:23:59 2006-12-27 14:23:59
#2: 2006-12-27 16:47:59 2006-12-27 16:47:59
#3: 2006-12-27 19:12:00 2006-12-27 19:12:00
setkey(wg)
foverlaps(wd, wg, nomatch = 0L)[, .(wdDate = Date, valu1, WGDate = start)]
# wdDate valu1 WGDate
#1: 2006-12-27 14:30:00 0.5 2006-12-27 16:47:59 <--- The matched times are incorrect
See this SO question for reference.
It'd be nice to, in general, warn when joining on POSIXct types with mismatched timezones.
Consider the following example
See this SO question for reference.
It'd be nice to, in general, warn when joining on POSIXct types with mismatched timezones.