summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/run.lisp14
1 files changed, 14 insertions, 0 deletions
diff --git a/database/run.lisp b/database/run.lisp
index 21d278a..a72f52e 100644
--- a/database/run.lisp
+++ b/database/run.lisp
@@ -16,6 +16,20 @@
(sxql:order-by :category_split_id)
(sxql:where (:= :run run))))
+;; Returns the elapsed time in milliseconds since split started to either
+;; current time or the split's end time
+(defun run-split-elapsed-time (run-split)
+ (let ((start (ignore-errors (run-split-start-time run-split)))
+ (end (or (ignore-errors (run-split-end-time run-split)) (local-time:now))))
+ (if start
+ (floor (* 1000 (local-time:timestamp-difference end start))))))
+
+(defun format-elapsed-time (run-split)
+ (let ((elapsed (run-split-elapsed-time run-split)))
+ (if elapsed
+ (format-time (make-time-alist elapsed))
+ "-")))
+
;; Returns stuff like PB, best of each split, etc.
(defun run-statistics (category)
`((asdf . 1)))