From 7488a74b86c7f95fea194d3534a6d7dc657de93c Mon Sep 17 00:00:00 2001 From: Brandon Bloom Date: Tue, 5 Jun 2012 22:04:59 -0700 Subject: [PATCH] Fix (= (js/Date.) nil Also cleans up time macro, which was passing .getTime an extra arg. --- src/clj/cljs/core.clj | 6 +++--- src/cljs/cljs/core.cljs | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/clj/cljs/core.clj b/src/clj/cljs/core.clj index 70c1509..b5d6e01 100644 --- a/src/clj/cljs/core.clj +++ b/src/clj/cljs/core.clj @@ -993,9 +993,9 @@ (defmacro time "Evaluates expr and prints the time it took. Returns the value of expr." [expr] - `(let [start# (.getTime (js/Date.) ()) + `(let [start# (.getTime (js/Date.)) ret# ~expr] - (prn (core/str "Elapsed time: " (- (.getTime (js/Date.) ()) start#) " msecs")) + (prn (core/str "Elapsed time: " (- (.getTime (js/Date.)) start#) " msecs")) ret#)) (defmacro simple-benchmark @@ -1041,4 +1041,4 @@ (if (zero? ~'argc) (~'f) ~(gen-apply-to-helper)))) - (set! ~'*unchecked-if* false))) \ No newline at end of file + (set! ~'*unchecked-if* false))) diff --git a/src/cljs/cljs/core.cljs b/src/cljs/cljs/core.cljs index cbea7d9..157fddb 100644 --- a/src/cljs/cljs/core.cljs +++ b/src/cljs/cljs/core.cljs @@ -308,6 +308,9 @@ (when-not (nil? x) (.-constructor x))) +(defn ^boolean instance? [t o] + (js* "(~{o} instanceof ~{t})")) + ;;;;;;;;;;;;;;;;;;; protocols on primitives ;;;;;;;; (declare hash-map list equiv-sequential) @@ -373,7 +376,9 @@ (extend-type js/Date IEquiv - (-equiv [o other] (identical? (. o (toString)) (. other (toString))))) + (-equiv [o other] + (and (instance? js/Date other) + (identical? (.toString o) (.toString other))))) (extend-type number IEquiv @@ -952,9 +957,6 @@ reduces them without incurring seq initialization" (defn ^boolean undefined? [x] (cljs.core/undefined? x)) -(defn ^boolean instance? [t o] - (js* "(~{o} instanceof ~{t})")) - (defn ^boolean seq? "Return true if s satisfies ISeq" [s] -- 1.7.9.1