c190ced000
1. chronometrist-events->time-list -> chronometrist-events->ts-pairs, now returns a list of ts pairs. Rewritten using cl-loop. 2. chronometrist-time-list->sum-of-intervals -> chronometrist-ts-pairs->durations, now returns a list of durations in integer seconds. 3. A critical bug in chronometrist-iso-timestamp->ts was discovered - we were passing the output of encode-time (via parse-iso8601-time-string) to (make-ts :unix ...) - the latter expects a number, not a list. 4. Both chronometrist-task-time-one-day and chronometrist-events->ts-pairs were checking if a task was still ongoing. Removed the redundant checking from the former. 5. Updated docstring of chronometrist-active-time-one-day 6. chronometrist-statistics-count-average-time-spent rewritten using cl-loop Also, when trying to write tests, I realized that chronometrist-events-clean has long been removed. Removed a reference to it from the manual and a docstring.
43 lines
2.1 KiB
EmacsLisp
43 lines
2.1 KiB
EmacsLisp
;;; -*- lexical-binding: t; -*-
|
|
(require 'buttercup)
|
|
(require 'chronometrist-common)
|
|
|
|
(describe
|
|
"chronometrist-format-time"
|
|
(it "works with lists"
|
|
(expect (chronometrist-format-time 0)
|
|
:to-equal " -")
|
|
(expect (chronometrist-format-time 1)
|
|
:to-equal " 1")
|
|
(expect (chronometrist-format-time 10)
|
|
:to-equal " 10")
|
|
(expect (chronometrist-format-time 70)
|
|
:to-equal " 1:10")
|
|
(expect (chronometrist-format-time (+ (* 10 60) ;; 10 minutes
|
|
10)) ;; 10 seconds
|
|
:to-equal " 10:10")
|
|
(expect (chronometrist-format-time (+ (* 1 60 60) ;; 1 hour
|
|
(* 10 60) ;; 10 minutes
|
|
10)) ;; 10 seconds
|
|
:to-equal " 1:10:10")
|
|
(expect (chronometrist-format-time (+ (* 10 60 60) ;; 10 hours
|
|
(* 10 60) ;; 10 minutes
|
|
10)) ;; 10 seconds
|
|
:to-equal "10:10:10")))
|
|
|
|
(describe
|
|
"chronometrist-previous-week-start"
|
|
:var ((chronometrist-report-week-start-day "Sunday")
|
|
(ts (chronometrist-iso-date->ts "2018-09-02")))
|
|
(it "should work with Sundays"
|
|
(should (ts= (chronometrist-previous-week-start
|
|
(chronometrist-iso-date->ts "2018-09-01"))
|
|
(chronometrist-iso-date->ts "2018-08-26")))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-02"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-03"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-04"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-05"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-06"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-07"))))
|
|
(should (ts= ts (chronometrist-previous-week-start (chronometrist-iso-date->ts "2018-09-08"))))))
|