       {:status 400, :body {:code 1, :reason "Value provided for :arrive-by must be a Date."}}
 
       :else
-      (if (.. arrive-by
-              (toInstant)
-              (isBefore (Instant/now)))
+      (if (date-before-today? arrive-by)
         {:status 200, :body {:code 2 :reason "No route available"}}
         (let [{:keys [status body] :as response} @(google-transit-directions
                                                    "Pennsylvania Station, New York, NY"

            [clj-time.coerce :as c]
            [clj-time.core :as t])
  (:import [java.util Date]
           [java.time ZonedDateTime Instant ZoneId DayOfWeek]
           [java.time.temporal ChronoUnit]))

(defn epoch-seconds->date [epoch-seconds]

                       (seconds->duration))}
     :route route}))

(defn date-before-today? [date]
  {:pre [(instance? java.util.Date date)]}
  (.. date
      (toInstant)
      (atZone (ZoneId/of "America/New_York"))
      (toLocalDate)
      (isBefore (LocalDate/now (ZoneId/of "America/New_York")))))

(defroutes routes
  (GET "/" []
    (response/resource-response "static/index.html"))
