From 45ec765798f17373d34b7f712e09f521a50033a6 Mon Sep 17 00:00:00 2001
From: Allen Gilliland <agilliland@gmail.com>
Date: Wed, 2 Mar 2016 08:27:26 -0800
Subject: [PATCH] couple more tweaks to is-temporal? plus unit tests.

---
 src/metabase/util.clj       | 7 +++----
 test/metabase/util_test.clj | 7 +++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/metabase/util.clj b/src/metabase/util.clj
index 53259c95183..2d541dd0773 100644
--- a/src/metabase/util.clj
+++ b/src/metabase/util.clj
@@ -85,11 +85,10 @@
 ;;; ## Date Stuff
 
 (defn is-temporal?
-  "Tests if the given VALUE is a temporal class such as `java.util.Date` or `org.joda.time.DateTime`."
+  "Is VALUE an instance of a datetime class like `java.util.Date` or `org.joda.time.DateTime`?"
   [v]
-  (and v
-       (or (instance? java.util.Date v)
-           (instance? org.joda.time.DateTime v))))
+  (or (instance? java.util.Date v)
+      (instance? org.joda.time.DateTime v)))
 
 (defn new-sql-timestamp
   "`java.sql.Date` doesn't have an empty constructor so this is a convenience that lets you make one with the current date.
diff --git a/test/metabase/util_test.clj b/test/metabase/util_test.clj
index 1fc7c259b56..44821c9e11a 100644
--- a/test/metabase/util_test.clj
+++ b/test/metabase/util_test.clj
@@ -9,6 +9,13 @@
 (def ^:private ^:const friday-the-13th   #inst "2015-11-13T19:05:55")
 (def ^:private ^:const saturday-the-14th #inst "2015-11-14T04:18:26")
 
+(expect false (is-temporal? nil))
+(expect false (is-temporal? 123))
+(expect false (is-temporal? "abc"))
+(expect false (is-temporal? [1 2 3]))
+(expect false (is-temporal? {:a "b"}))
+(expect true (is-temporal? friday-the-13th))
+
 (expect friday-the-13th (->Timestamp (->Date friday-the-13th)))
 (expect friday-the-13th (->Timestamp (->Calendar friday-the-13th)))
 (expect friday-the-13th (->Timestamp (->Calendar (.getTime friday-the-13th))))
-- 
GitLab