         task_id: task.id
       this.request(msg).path("/daily/add").post(JSON.stringify(data)) (err, res, body) ->
         callback res.statusCode, JSON.parse(body)
+
+  # Issues /daily/timer/<id> to the Harvest API to stop
+  # the timer running at `entry.id`. If that timer isn't
+  # running, replys accordingly, otherwise calls the callback
+  # when the operation has finished.
+  stop_entry: (msg, entry, callback) ->
+    if entry.timer_started_at?
+      this.request(msg).path("/daily/timer/#{entry.id}").get() (err, res, body) ->
+        callback res.statusCode, JSON.parse(body)
+    else
+      msg.reply "This timer is not running."
+
+  # Issues /daily/timer/<id> to the Harvest API to stop
+  # the timer running at <id>, which is determined by
+  # looking up the current day_entry for the given
+  # project/task combination. If no entry is found (i.e.
+  # no timer has been started for this combination today),
+  # replies with an error message and doesn't executes the
+  # callback.
+  stop: (msg, target_project, target_task, callback) ->
+    this.find_day_entry msg, target_project, target_task, (entry) =>
+      this.stop_entry msg, entry, (status, body) -> callback status, body
 
   # (internal method)
   # Assembles the basic parts of a request to the Harvest

        return

      # Execute the callback with the results
      callback projects[0], tasks[0]

  # Kick off a new timer, stopping the previously running one, if any.
  robot.respond /start harvest at (.+)\/(.+): (.*)/i, (msg) ->
    user    = msg.message.user
    project = msg.match[1]
    task    = msg.match[2]
    notes   = msg.match[3]

    # Check if we know the detected user's credentials.
    unless user.harvest_account
      msg.reply "You have to tell me your Harvest credentials first."
      return
    
    user.harvest_account.start msg, project, task, notes, (status, body) ->
      if 200 <= status <= 299
        if body.hours_for_previously_running_timer?
          msg.reply "Previously running timer stopped at #{body.hours_for_previously_running_timer}h."
        msg.reply "Started tracking. Back to your work, #{msg.message.user.name}!"
      else
        msg.reply "Request failed with status #{status}."

  # Stops the timer running for a project/task combination,
  # if any.
  robot.respond /stop harvest at (.+)\/(.+)/i, (msg) ->
    user    = msg.message.user
    project = msg.match[1]
    task    = msg.match[2]
    unless user.harvest_account
      msg.reply "You have to tell me your Harvest credentials first."
      return
    
    user.harvest_account.stop msg, project, task, (status, body) ->
      if 200 <= status <= 299
        msg.reply "Timer stopped."
      else
        msg.reply "Request failed with status #{status}."
        msg.reply body

  # Stop the first running timer it can find.
  # Not yet implemented.
  #robot.respond /stop harvest/i, (msg) ->
  #  msg.reply "Not yet implemented."

# Class managing the Harvest account associated with
# a user. Keeps track of the user's credentials and can
