I know this is the "answer", but these problems still exist for 32-bit R, there is an inconsistency in the implementation between 32-bit and 64-bit versions. The truncation problem is partially true, but this is not the result of the strptime function, but the print.POSIXlt method in this particular case.
This can be demonstrated by overwriting a function with a function that causes the expected behavior. For instance.
print.POSIXlt = function(posix) { print(paste0(posix$year+1900,"-",sprintf("%02d",posix$mon+1),"-",sprintf("%02d",posix$mday)," ", sprintf("%02d",posix$hour),":",sprintf("%02d",posix$min),":",sprintf("%002.003f",posix$sec))) }
Now the time is displayed as expected:
> strptime("2007-03-30 15:00:00.009", format = "%Y-%m-%d %H:%M:%OS"); [1] "2007-03-30 15:00:0.009"
For more information, I examined this R problem with rounding milliseconds
source share