Function: timeclock-in

timeclock-in is an autoloaded, interactive and byte-compiled function defined in timeclock.el.gz.

Signature

(timeclock-in &optional ARG PROJECT FIND-PROJECT)

Documentation

Clock in, recording the current time moment in the timelog.

With a numeric prefix ARG, record the fact that today has only that many hours in it to be worked. If ARG is a non-numeric prefix argument
(non-nil, but not a number), 0 is assumed (working on a holiday or
weekend). *If not called interactively, ARG should be the number of
_seconds_ worked today*. This feature only has effect the first time
this function is called within a day.

PROJECT is the project being clocked into. If PROJECT is nil, and FIND-PROJECT is non-nil -- or the user calls timeclock-in interactively -- call the function timeclock-get-project-function to discover the name of the project.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/timeclock.el.gz
;;;###autoload
(defun timeclock-in (&optional arg project find-project)
  "Clock in, recording the current time moment in the timelog.
With a numeric prefix ARG, record the fact that today has only that
many hours in it to be worked.  If ARG is a non-numeric prefix argument
\(non-nil, but not a number), 0 is assumed (working on a holiday or
weekend).  *If not called interactively, ARG should be the number of
_seconds_ worked today*.  This feature only has effect the first time
this function is called within a day.

PROJECT is the project being clocked into.  If PROJECT is nil, and
FIND-PROJECT is non-nil -- or the user calls `timeclock-in'
interactively -- call the function `timeclock-get-project-function' to
discover the name of the project."
  (interactive
   (list (and current-prefix-arg
	      (if (numberp current-prefix-arg)
		  (* current-prefix-arg 60 60)
		0))))
  (if (equal (car timeclock-last-event) "i")
      (error "You've already clocked in!")
    (unless timeclock-last-event
      (timeclock-reread-log))
    ;; Either no log file, or day has rolled over.
    (unless (and timeclock-last-event
                 (equal (timeclock-time-to-date
                         (cadr timeclock-last-event))
                        (timeclock-time-to-date)))
      (let ((workday (or (and (numberp arg) arg)
			 (and arg 0)
			 (and timeclock-get-workday-function
			      (funcall timeclock-get-workday-function))
			 timeclock-workday)))
	(run-hooks 'timeclock-first-in-hook)
	;; settle the discrepancy for the new day
	(setq timeclock-discrepancy
	      (- (or timeclock-discrepancy 0) workday))
	(if (not (= workday timeclock-workday))
	    (timeclock-log "h" (number-to-string
				(/ workday (if (zerop (% workday (* 60 60)))
					       60 60.0)
                                   60))))))
    (timeclock-log "i" (or project
			   (and timeclock-get-project-function
				(or find-project
				    (called-interactively-p 'interactive))
				(funcall timeclock-get-project-function))))
    (run-hooks 'timeclock-in-hook)))