--- json.php.orig	2006-06-16 02:36:39.000000000 +0200
+++ json.php	2006-06-16 02:49:12.000000000 +0200
@@ -82,6 +82,11 @@
 define('SERVICES_JSON_IN_CMT', 5);
 
 /**
+* Marker constant for JSON::decode(), used to flag stack state
+*/
+define('SERVICES_JSON_IN_DATE',  6);
+
+/**
 * Behavior switch for JSON::decode()
 */
 define('SERVICES_JSON_LOOSE_TYPE', 16);
@@ -658,7 +663,7 @@
                             // OR we've reached the end of the character list
                             $slice = substr($chrs, $top['where'], ($c - $top['where']));
                             array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
-                            //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+                            print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
                             if (reset($stk) == SERVICES_JSON_IN_ARR) {
                                 // we are in an array, so just push an element onto the stack
@@ -695,6 +700,14 @@
 
                             }
 
+                        } elseif (preg_match("/^new Date\(Date\.UTC\(/", substr($chrs, $c)) && ($top['what'] != SERVICES_JSON_IN_DATE)) {
+                            // found a date start, and we are not inside a date
+                            array_push($stk, array('what' => SERVICES_JSON_IN_DATE, 'where' => $c));
+                            print("Found start of date at {$c}\n");
+                        } elseif (preg_match("/^\)\)/", substr($chrs, $c)) && $top['what'] == SERVICES_JSON_IN_DATE) {
+                            // found the end of a date
+                            array_pop($stk);
+                            print("Found end of date at {$c}\n");
                         } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
                             // found a quote, and we are not inside a string
                             array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
@@ -758,7 +771,7 @@
                         return $obj;
 
                     }
-                } else if (preg_match("/^new Date\((\"|\')([0-9]+)-([0-9]+)-([0-9]+)T([0-9]+):([0-9]+):([0-9]+)(\.([0-9]+))?Z(\"|\')\)/s", $str, $m) && $m[1] == $m[10]) {
+                } else if (preg_match("/^new Date\(Date\.UTC\(([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+)(,([0-9]+))?\)\)/s", $str, $m)) {
                     /*
                      * Test program to see the sub-strings:
                      *
@@ -789,9 +802,9 @@
                      * $m[10]: a quote
                      */
                     $obj = new JSON_Date();
-                    $obj->setUtcDateTimeFields($m[2], $m[3], $m[4],
-                                               $m[5], $m[6], $m[7],
-                                               $m[9]);
+                    $obj->setUtcDateTimeFields($m[1], $m[2], $m[3],
+                                               $m[4], $m[5], $m[6],
+                                               $m[8]);
                     return $obj;
                 }
         }
