Change to centiseconds across the program
This commit is contained in:
parent
84e566e92b
commit
10d7a20a79
@ -22,7 +22,7 @@
|
||||
(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))))))
|
||||
(floor (* 100 (local-time:timestamp-difference end start))))))
|
||||
|
||||
(defun format-elapsed-time (run-split)
|
||||
(let ((elapsed (run-split-elapsed-time run-split)))
|
||||
|
@ -44,7 +44,7 @@
|
||||
;; Updates the current total elapsed time of the speedrun if it's running
|
||||
(defun update-time (speedrun)
|
||||
(if (eq (speedrun-state speedrun) 'RUNNING)
|
||||
(setf (speedrun-elapsed speedrun) (* 1000 (/ (- (get-internal-real-time) (speedrun-start-timestamp speedrun)) internal-time-units-per-second)))))
|
||||
(setf (speedrun-elapsed speedrun) (floor (* 100 (/ (- (get-internal-real-time) (speedrun-start-timestamp speedrun)) internal-time-units-per-second))))))
|
||||
|
||||
;; Initializes a speedrun to start running the timer
|
||||
(defun start-speedrun (speedrun)
|
||||
@ -64,7 +64,9 @@
|
||||
(setf (run-split-end-time (current-split speedrun)) now)
|
||||
(if (equal (speedrun-current-split-index speedrun) (1- (length (speedrun-splits speedrun))))
|
||||
(progn
|
||||
(setf (speedrun-state speedrun) 'STOPPED)
|
||||
(setf
|
||||
(speedrun-elapsed speedrun) (apply '+ (mapcar 'run-split-elapsed-time (speedrun-splits speedrun)))
|
||||
(speedrun-state speedrun) 'STOPPED)
|
||||
(save-speedrun speedrun))
|
||||
(progn
|
||||
(inc (speedrun-current-split-index speedrun))
|
||||
|
14
time.lisp
14
time.lisp
@ -1,9 +1,9 @@
|
||||
;; Makes a-list with '((hours . HOURS) (minutes . MINUTES) (seconds . SECONDS) (ms . MILLISECONDS))
|
||||
(defun make-time-alist (ms)
|
||||
`((hours . ,(floor (/ ms (* 1000 60 60))))
|
||||
(minutes . ,(floor (mod (/ ms (* 1000 60)) 60)))
|
||||
(seconds . ,(floor (mod (/ ms 1000) 60)))
|
||||
(ms . ,(mod ms 1000))))
|
||||
;; Makes a-list with '((hours . HOURS) (minutes . MINUTES) (seconds . SECONDS) (cs . CENTISECONDS))
|
||||
(defun make-time-alist (cs)
|
||||
`((hours . ,(floor (/ cs (* 100 60 60))))
|
||||
(minutes . ,(floor (mod (/ cs (* 100 60)) 60)))
|
||||
(seconds . ,(floor (mod (/ cs 100) 60)))
|
||||
(cs . ,(mod cs 100))))
|
||||
|
||||
;; Formats, disregarding min/hour if they shouldn't be shown, a time alist to "H:M:S.ms"
|
||||
(defun format-time (time-alist)
|
||||
@ -11,7 +11,7 @@
|
||||
((hours (cdr (assoc 'hours time-alist)))
|
||||
(minutes (cdr (assoc 'minutes time-alist)))
|
||||
(seconds (cdr (assoc 'seconds time-alist)))
|
||||
(centis (round (/ (cdr (assoc 'ms time-alist)) 10))))
|
||||
(centis (cdr (assoc 'cs time-alist))))
|
||||
(concatenate 'string
|
||||
(unless (zerop hours) (format nil "~2,'0d:" hours))
|
||||
(unless (and (zerop minutes) (zerop hours)) (format nil "~2,'0d:" minutes))
|
||||
|
Loading…
Reference in New Issue
Block a user