On Wed, Jan 27, 2010 at 11:18 PM, Dirkjan Ochtman <djc.ocht...@gmail.com> wrote:
> On Thu, Jan 28, 2010 at 01:06, Chris Anderson <jch...@apache.org> wrote:
>> Is anyone else having trouble with views that emit Date objects in the
>> key (running latest trunk)?
>
> From memory, I wonder if emitting Date objects for
> JSON.stringification is valid according to the spec. I remember that
> the Firefox JSON implementation was somewhat restrictive about what it
> allowed to be passed to JSON.stringify at first, but I don't remember
> the exact rules.
>
> One difference I think is that in SpiderMonkey 1.7 you don't have
> built-in JSON (so you fall back to actual json2.js). I'm not sure
> exactly when that was introduced, but it might well be in SM 1.8.
>
> Cheers,
>
> Dirkjan
>

I think we can help here by defining some prototypes, like:


Date.prototype.toJSON = function(k) {
  var v = this;
  var f = function(n) { return n < 10 ? '0' + n : n };
  return '"' + v.getUTCFullYear()   + '-' +
             f(v.getUTCMonth() + 1) + '-' +
             f(v.getUTCDate())      + 'T' +
             f(v.getUTCHours())     + ':' +
             f(v.getUTCMinutes())   + ':' +
             f(v.getUTCSeconds())   + 'Z"';
}

David, you could even try defining this in your map view and see if that helps.

Chris

-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Reply via email to