      :milliseconds (.getUTCMilliseconds d)}))
 
 (defn display-time [tm]
+"return str of mins secs and millisecs with padding"
   (let [pad (fn [n]
               (if (< n 10)
                 (str "0" n)

    (str mm ":" ss ":" ms)))

(defn keep-time [func]
  (if (zero? @break-timer)
    (do
      (reset)
      
      (start)))
  (if (zero? @start-timer)
    (do
      (reset! break-time? 1)
      (swap! break-timer func))
    (do
      (reset! break-time? 0)
      
      (swap! start-timer func))))

(defn pause []
  (when (time-active?)
    (reset! time-active 0)
    (js/clearInterval @interval)))

(defn start []
  (reset! time-active 1)
  (reset! interval (js/setInterval #(keep-time @time-fn) 10)))

(defn reset []
  (let [starting (fn [n] ;; cap input at 59 mins
                   (if (< n 60)
                     n
                     59))]
    (reset! break-time? 0)
    (reset! time-active 0)
    (js/clearInterval @interval)
    (reset! start-timer (* 60 (* 100 (starting  @start-time))))
    (reset! break-timer (* 60 (* 100 @break-time)))))

(defn start-time-input []
  [:div.start-input
   "Set working timer (in minutes): "
   [:input {:type "text"
            :value @start-time
            :on-change #(reset! start-time (-> % .-target .-value))}]
   [:button {:on-click (fn [ev] (reset))} "Set!"]])

(defn break-time-input []


(defn work-clock []
  [:div
   [:h1 (when @time-active?
          (if @break-time?            
            "Break time!!"
            "Get to work!!")) ]
   [start-time-input]
   [break-time-input]
   [:h1.work-clock  {:class (if @break-time?
                              "hide"
                              "show-work"                              
                              )} (display-time (seconds-to-time @work-timer))]
   [:h1.break-clock {:class (if @break-time?                              
                              (if (< @break-timer 3000)
                                "show-break warning"
                                "show-break")
                              "hide"
                              )} (display-time (seconds-to-time @break-timer))]
   [:button {:on-click (fn [ev] (start))} "Start!"]
   [:button {:on-click (fn [ev] (pause))} "Pause!"]
