 
   IComparable
   (-compare [this other]
-    (garray/defaultCompare (.valueOf this) (.valueOf other))))
+    (if (instance? js/Date other)
+      (garray/defaultCompare (.valueOf this) (.valueOf other))
+      (throw (js/Error. (str "Cannot compare " this " to " other))))))
 
 (extend-type number
   IEquiv


   (nil? y) 1

   (identical? (type x) (type y))
   (if (implements? IComparable x)
     (-compare ^not-native x y)
     (garray/defaultCompare x y))

   :else
   (throw (js/Error. "compare on non-nil objects of different types"))))

(defn ^:private compare-indexed
  "Compare indexed collection."

;; IComparable
(extend-protocol IComparable
  Symbol
  (-compare [x y]
    (if (symbol? y)
      (compare-symbols x y)
      (throw (js/Error. (str "Cannot compare " x " to " y)))))

  Keyword
  (-compare [x y]
    (if (keyword? y)
      (compare-keywords x y)
      (throw (js/Error. (str "Cannot compare " x " to " y)))))

  Subvec
  (-compare [x y]
    (if (vector? y)
      (compare-indexed x y)
      (throw (js/Error. (str "Cannot compare " x " to " y)))))
  
  PersistentVector
  (-compare [x y]
    (if (vector? y)
      (compare-indexed x y)
      (throw (js/Error. (str "Cannot compare " x " to " y))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Reference Types ;;;;;;;;;;;;;;;;

