1

Closed

Date and time marshalling: R type should not be Date

description

Date is effectively limited to being useful for daily data. I need a close look at the date-time handling system in R and choose the right conversion. Picking the wrong things here could have some far reaching impact in the future.
Closed Jun 29, 2013 at 8:44 AM by jperraud
Works with POSIXct now and quite extensively tested; on Mono an issue however. The fact that R POSIXct are DST aware makes things complicated however. Pros/cons. May need to reenable simpler conversions for data above the daily resolution.

comments

jperraud wrote May 23, 2013 at 12:47 AM

Started the process. Bumped in the first issue with time zone.
See also r2clr\doc\notes_datetime.txt
  clrDate <- clrCallStatic(cTypename, "CreateDate", testDateStr)
> str(clrDate)
 POSIXct[1:1], format: "2001-01-01 01:00:00"
> str(as.POSIXct(testDateStr))
 POSIXct[1:1], format: "2001-01-01"
> attributes(clrDate)
$class
[1] "POSIXct" "POSIXt" 

> attributes(as.POSIXct(testDateStr))
$class
[1] "POSIXct" "POSIXt" 

$tzone
[1] ""
The clrDate is calculated by offsetting a double, in C code. I don't think the tzone difference is the main thing that matters:

Testing on a machine with local time zone settings to Canberra, Australia
> as.numeric(as.POSIXct('2013-04-07 02:33')) - as.numeric(as.POSIXct('2013-04-07 02:32'))
[1] 3660
> as.numeric(as.POSIXct('2013-04-07 02:33')) - as.numeric(as.POSIXct('2013-04-07 02:32:30'))
[1] 30