Permalink
Browse files

Fix (= (js/Date.) nil

Also cleans up time macro, which was passing .getTime an extra arg.
  • Loading branch information...
1 parent 9ad79e1 commit 80726438d7375eb72cd4ea82a7ea676d3237b6ce @brandonbloom brandonbloom committed with David Nolen Jun 6, 2012
Showing with 9 additions and 7 deletions.
  1. +3 −3 src/clj/cljs/core.clj
  2. +6 −4 src/cljs/cljs/core.cljs
@@ -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)))
+ (set! ~'*unchecked-if* false)))
@@ -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]

0 comments on commit 8072643

Please sign in to comment.