(setq work-time-start 9)
(setq work-time-end 17)
(setq work-time-statuslen 16)
;
(defun work-time-update nil
(let* ((now (current-time))
(today (let ((dcd-now (decode-time now)))
`(,(nth 3 dcd-now) ,(nth 4 dcd-now) ,(nth 5 dcd-now))))
(start-time (apply #'encode-time (append (list 0 0 work-time-start) today)))
(end-time (apply #'encode-time (append (list 0 0 work-time-end) today))))
(labels ((status-string-format (perc)
(cond ((< perc 0) ":(")
((> perc 1) ":))")
(t (let* ((filled (round (* perc work-time-statuslen)))
(empty (- work-time-statuslen filled)))
(concat "[ (make-string filled ?#) (make-string empty ?\ ) ]")))))
(elapsed-percentage (from to now) (/ (float (- now from))(- to from)))
(total-sec (time) (+ (* 65536 (car time)) (cadr time))))
(setq wt-status-string
(status-string-format
(elapsed-percentage (total-sec start-time) (total-sec end-time) (total-sec now)))))))
(push #'work-time-update display-time-hook)
;
(defun wt-status-displayed nil
(member 'wt-status-string global-mode-string))
(defun wt-add-status nil
(setq global-mode-string (append global-mode-string '(wt-status-string))))
(defun wt-remove-status nil
(setq global-mode-string (remove 'wt-status-string global-mode-string)))
(defun work-time-status-toggle nil
(interactive)
(funcall (if (wt-status-displayed) #'wt-remove-status #'wt-add-status)))
;
(setq wt-status-string (work-time-update))
;;;todo
;;add minutes
;;works only as display time hook
original Aug 7 2:45am