Index: src/js/json.js |
diff --git a/src/js/json.js b/src/js/json.js |
index ee3b9dceea217062f077131c5807b3716352a6e5..b8836eaddd919fb9387c962391f4075e7df8e302 100644 |
--- a/src/js/json.js |
+++ b/src/js/json.js |
@@ -11,6 +11,7 @@ |
// ------------------------------------------------------------------- |
// Imports |
+var GlobalDate = global.Date; |
var GlobalJSON = global.JSON; |
var GlobalSet = global.Set; |
var InternalArray = utils.InternalArray; |
@@ -247,6 +248,24 @@ utils.InstallFunctions(GlobalJSON, DONT_ENUM, [ |
]); |
// ------------------------------------------------------------------- |
+// Date.toJSON |
+ |
+// 20.3.4.37 Date.prototype.toJSON ( key ) |
+function DateToJSON(key) { |
+ var o = TO_OBJECT(this); |
+ var tv = TO_PRIMITIVE_NUMBER(o); |
+ if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) { |
+ return null; |
+ } |
+ return o.toISOString(); |
+} |
+ |
+// Set up non-enumerable functions of the Date prototype object. |
+utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [ |
+ "toJSON", DateToJSON |
+]); |
+ |
+// ------------------------------------------------------------------- |
// JSON Builtins |
function JsonSerializeAdapter(key, object) { |