 (def micromanager (file* "../.."))
 
 (def MS-PER-HOUR (* 60 60 1000))
+
+(def today-token
+  (let [format (SimpleDateFormat. "yyyyMMdd")
+        one-hour-ago (doto (Calendar/getInstance)
+                       (.add Calendar/HOUR -1))]
+    (.format format (.getTime one-hour-ago))))
+    
+(def yyyymmdd (SimpleDateFormat. "yyyyMMdd"))
+
+(doto (Calendar/getInstance) (.add Calendar/HOUR -1))
 
 (defn result-file [bits mode]
   (File. micromanager (str "/result" bits (name mode) ".txt")))

      (file-seq dir))
    time-limit-hours))

(defn report-build-errors [bits mode]
  (let [f (result-file bits mode)
        result-txt (slurp f)

                                         32 "bin_Win32"
                                         64 "bin_x64")) 24)
        javac-errs (javac-errors result-txt)
        outdated-jars (old-jars (File. micromanager "Install_AllPlatforms") 24)
        installer-ok (exe-on-server? bits today-token)]
    (when-not (and (empty? vs-error-text) (empty? outdated-dlls)
                   (empty? javac-errs) (empty? outdated-jars)
                   installer-ok)
      (str
        "\n\nMICROMANAGER " bits "-bit "
          ({:inc "INCREMENTAL" :full "FULL"} mode)
          " BUILD ERROR REPORT\n"
        "For the full build output, see " (.getAbsolutePath f)
        "\n\nVisual Studio reported errors:"
        (if-not (empty? vs-error-text)
          vs-error-text
          "None.")
        "\n\nOutdated device adapter DLLs:\n"
        (if-not (empty? outdated-dlls)
          (str-lines "\n" (map #(.getName %) outdated-dlls))
          "None.")
          "\n\nErrors reported by java compiler:\n"
        (if-not (empty? javac-errs)
          (str-lines "\n" javac-errs)
          "None.")
        "\n\nOutdated jar files:\n"
        (if-not (empty? outdated-jars)
          (str-lines "\n" (map #(.getName %) outdated-jars))
          "None.")
        "\n\nIs installer download available on website?\n"
        (if installer-ok
          "Yes"
          "No. (build missing)\n")
      ))))

(defn make-full-report [mode send?]
  (let [report
        (str
          (report-build-errors 32 mode)
          (report-build-errors 64 mode))]
    (if-not (empty? report)
