Display durations using format-seconds
This commit is contained in:
parent
db965525b0
commit
339d5da1e7
|
@ -822,8 +822,9 @@ treated as though their time is 00:00:00."
|
|||
:CUSTOM_ID: task-duration-one-day
|
||||
:END:
|
||||
#+BEGIN_SRC lisp
|
||||
(defun task-duration-one-day (task &optional (date (timestamp-to-unix (today)))
|
||||
(backend (active-backend)))
|
||||
(defun task-duration-one-day (task &optional
|
||||
(date (timestamp-to-unix (today)))
|
||||
(backend (active-backend)))
|
||||
"Return total time spent on TASK today or on DATE.
|
||||
The return value is seconds, as an integer."
|
||||
(let ((task-intervals (task-records-for-date backend task date)))
|
||||
|
@ -3019,26 +3020,27 @@ s-expressions in a text column.")
|
|||
|
||||
**** task-records-for-date
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: task-records-for-date-3
|
||||
:CUSTOM_ID: sqlite-task-records-for-date
|
||||
:END:
|
||||
#+BEGIN_SRC lisp
|
||||
(defmethod chronometrist:task-records-for-date
|
||||
((backend sqlite-backend) task date &key &allow-other-keys)
|
||||
(let ((list (execute-sxql #'execute-to-list
|
||||
(select (:name :start_time :stop_time :properties)
|
||||
(from :intervals)
|
||||
(left-join :interval_names :using (:name_id))
|
||||
(left-join :properties :using (:prop_id))
|
||||
(where (:and
|
||||
(:in :interval_id
|
||||
(select (:interval_id)
|
||||
(from :date_intervals)
|
||||
(where (:= :date_id
|
||||
(select (:date_id)
|
||||
(from :dates)
|
||||
(where (:= :date date)))))))
|
||||
(:= :name task))))
|
||||
(backend-connection backend))))
|
||||
(let ((list (execute-sxql
|
||||
#'execute-to-list
|
||||
(select (:name :start_time :stop_time :properties)
|
||||
(from :intervals)
|
||||
(left-join :interval_names :using (:name_id))
|
||||
(left-join :properties :using (:prop_id))
|
||||
(where (:and
|
||||
(:in :interval_id
|
||||
(select (:interval_id)
|
||||
(from :date_intervals)
|
||||
(where (:= :date_id
|
||||
(select (:date_id)
|
||||
(from :dates)
|
||||
(where (:= :date date)))))))
|
||||
(:= :name task))))
|
||||
(backend-connection backend))))
|
||||
(loop for (name start stop prop-string) in list
|
||||
collect (make-interval name start stop prop-string))))
|
||||
#+END_SRC
|
||||
|
@ -3091,11 +3093,21 @@ s-expressions in a text column.")
|
|||
(defpackage :chronometrist.clim
|
||||
(:use :clim :clim-lisp)
|
||||
(:import-from :local-time :now :today :timestamp-to-unix)
|
||||
(:import-from :format-seconds :format-seconds)
|
||||
(:import-from :chronometrist :task-list :task-duration-one-day)
|
||||
(:export :run-chronometrist))
|
||||
(in-package :chronometrist.clim)
|
||||
#+END_SRC
|
||||
|
||||
**** *duration-format-string* :variable:
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: duration-format-string
|
||||
:END:
|
||||
#+BEGIN_SRC lisp
|
||||
(defvar *duration-format-string* "~2h:~2,'0m:~2,'0s"
|
||||
"Format string used for durations, acceptable to `format-seconds'.")
|
||||
#+END_SRC
|
||||
|
||||
**** chronometrist :application:frame:
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: chronometrist-1
|
||||
|
@ -3195,12 +3207,14 @@ FRAME and PANE are the CLIM frame and pane as passed to the display function."))
|
|||
duration
|
||||
frame pane)
|
||||
(with-output-as-presentation (pane duration 'number)
|
||||
(format t "~A" duration)))
|
||||
(if (zerop duration)
|
||||
(format t "~10@A" "-")
|
||||
(format-seconds t *duration-format-string* duration))))
|
||||
#+END_SRC
|
||||
|
||||
***** *task-duration-table-spec* :custom:variable:
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: *task-duration-table-spec*
|
||||
:CUSTOM_ID: task-duration-table-spec
|
||||
:END:
|
||||
#+BEGIN_SRC lisp
|
||||
(defvar *task-duration-table-spec*
|
||||
|
|
Reference in New Issue