On Tue, Feb 09, 2010 at 09:01:06AM -0800, Chris Anderson wrote:
> On Tue, Feb 9, 2010 at 3:10 AM, Brian Candler <b.cand...@pobox.com> wrote:
> > FWIW, I get the same with 0.10.1 so it doesn't appear to be a regression.
> > Both current and 0.10.1 were built under Ubuntu Hardy with spidermonkey
> > 1.8.1.18
> 
> On thing that could be impacting this: json2.js prefers to drop back
> to a native JSON serializer if one is available. This means
> differences in spidermonkey version could conceivably give different
> date formats.
> 
> For what it's worth, this is what I'm seeing when serializing date
> objects on my end:
> 
> "2010-02-09T06:26:44.355Z"

Ah, there appears to be a difference between new Date(n) and Date().

Here are the results again, this time built on a newer machine (Ubuntu
Karmic):

$ curl -d'{"map":"function(doc) { emit(new Date(0),null);}"}' -X POST 
http://127.0.0.1:5984/briantest/_temp_view
{"total_rows":1,"offset":0,"rows":[
{"id":"foo","key":"1970-01-01T00:00:00.000Z","value":null}
]}
$ curl -d'{"map":"function(doc) { emit(Date(),null);}"}' -X POST 
http://127.0.0.1:5984/briantest/_temp_view
{"total_rows":1,"offset":0,"rows":[
{"id":"foo","key":"Tue Feb 09 2010 18:26:08 GMT+0000 (BST)","value":null}
]}
$ curl -d'{"map":"function(doc) { emit(toJSON(Date()),null);}"}' -X POST 
http://127.0.0.1:5984/briantest/_temp_view
{"total_rows":1,"offset":0,"rows":[
{"id":"foo","key":"\"Tue Feb 09 2010 18:27:05 GMT+0000 (BST)\"","value":null}
]}

Is it defined that Date() always returns a string, not a Date object??

Built as follows:

$ cat build-local.sh
PREFIX=/v/build/couchdb
./bootstrap &&
LD_RUN_PATH=/usr/lib/xulrunner-1.9.1.7 ./configure --prefix=$PREFIX \
  --with-js-lib=/usr/lib/xulrunner-1.9.1.7 \
  --with-js-include=/usr/lib/xulrunner-devel-1.9.1.7/include &&
LD_RUN_PATH=/usr/lib/xulrunner-1.9.1.7 make &&
sudo rm -rf $PREFIX/couchdb/erlang/lib/couch-* &&
sudo make install &&
grep chown README | sed -e "s#/usr/local#$PREFIX#g" | sudo sh
grep chmod README | sed -e "s#/usr/local#$PREFIX#g" -e 's#0770#0775#g' |
sudo sh
sudo $PREFIX/etc/init.d/couchdb restart

$ curl http://127.0.0.1:5984
{"couchdb":"Welcome","version":"0.11.0bcc31819f-git"}

Regards,

Brian.

Reply via email to