Starcounter-Jack/JSON-Patch — pull request #2 by jrogelstad (2013-04-27 18:14:42+00:00)
Title: Fix problem where date comparison always yields a patch.

When you do a comparison on an object that includes dates, all dates end up resulting in patches. This is because JSON.parse(JSON.stringify)) is used to generate an internal cache object, but that does not result in an object with identical values. Dates get converted to strings:

d = new Date();
foo = {x: 10, y: "test", z: d};
jsonpatch.observe(foo);
bar = jsonpatch.observe(foo);
jsonpatch.generate(bar);

The proposed fix is imperfect insofar as it does not correct the date to string conversion but instead just rolls with it by giving the object variable to be compared against the original cached version the same treatment. This works for us, and probably most people, because the end goal is to generate JSON patches to be transmitted as text where the dates will end up becoming strings anyway.

This is a really simple and slick implementation of rfc6902 by the way. Thanks for publishing it.