gerald-lindsly / rmongodb

R driver for MongoDB
http://cnub.org/rmongodb.ashx
Apache License 2.0
83 stars 44 forks source link

POSIXct expects seconds, gets millis #1

Closed rothfels closed 13 years ago

rothfels commented 13 years ago

I downloaded and started using this package yesterday, but found that all POSIXct objects in R were incorrect (for example, we expect the date '2010-08-10' but see '1917-xx-xx' or '2048-xx-xx' in R). After poking around in the source, I found that many POSIXct objects are constructed with the value returned by bson_iterator_date, which is a 64-bit integer representing millis since epoch. However, POSIXct objects expect seconds since epoch. I seem to have fixed the problem by finding all calls to bson_iterator_date used to construct POSIXct and dividing the value returned by 1000. There were 3 such lines in api_bson.c. I may be missing other places where this is still a problem though.

gerald-lindsly commented 13 years ago

You are right. I fixed it. Thanks. There's also the inverse of multiplying by 1000 when appending into a bson. This is fixed also.

On Sat, Oct 1, 2011 at 5:59 PM, rothfels < reply@reply.github.com>wrote:

I downloaded and started using this package yesterday, but found that all POSIXct objects in R were incorrect (for example, we expect the date '2010-08-10' but see '1917-xx-xx' or '2048-xx-xx' in R). After poking around in the source, I found that many POSIXct objects are constructed with the value returned by bson_iterator_date, which is a 64-bit integer representing millis since epoch. However, POSIXct objects expect seconds since epoch. I seem to have fixed the problem by finding all calls to bson_iterator_date used to construct POSIXct and dividing the value returned by 1000. There were 3 such lines in api_bson.c. I may be missing other places where this is still a problem though.

Reply to this email directly or view it on GitHub: https://github.com/gerald-lindsly/rmongodb/issues/1