(format " %f %f\n" hours sum))))
(setq tbl (cdr tbl)))))
+(defun org-dblock-write:invoicerounding (params)
+ "Grab hours in a format suitable for an invoice, rounding all times to a full hour"
+ (let* ((ts (plist-get params :tstart))
+ (te (plist-get params :tend))
+ (ins (make-marker))
+ (start (time-to-seconds
+ (apply 'encode-time (org-parse-time-string ts))))
+ (end (time-to-seconds
+ (apply 'encode-time (org-parse-time-string te))))
+ tbl sum)
+
+ (setq params (plist-put params :tstart nil))
+ (setq params (plist-put params :end nil))
+ (move-marker ins (point))
+ (while (<= start end)
+ (save-excursion
+ (let ((sum 0))
+ (org-clock-sum start (+ start 86400))
+ (goto-char (point-min))
+ (setq st t)
+ (while (or (and (bobp) (prog1 st (setq st nil))
+ (get-text-property (point) :org-clock-minutes)
+ (setq p (point-min)))
+ (setq p (next-single-property-change (point) :org-clock-minutes)))
+ (goto-char p)
+ (message (format "pre: %s %d %d %s" (format-time-string "%Y-%m-%d" (seconds-to-time start)) sum start (point)))
+ (if (= 1 (car (org-heading-components)))
+ (setq sum (+ sum (or (get-text-property p :org-clock-minutes) 0)))))
+ (push (list start sum) tbl)))
+ (setq start (+ 86400 start)))
+ (setq tbl (nreverse tbl))
+ (goto-char ins)
+ (setq sum 0)
+ (while tbl
+ (let* ((line (car tbl))
+ (ts (seconds-to-time (first line)))
+ (minutes (second line))
+ (hours (minutes-to-hours minutes)))
+ (setq sum (+ sum hours))
+ (if (not (weekend-p ts))
+ (setq sum (- sum 7.5)))
+ (if (> minutes 0)
+ (insert-before-markers
+ (format-time-string "%Y-%m-%d" ts)
+ (format " %f %f\n" hours sum))))
+ (setq tbl (cdr tbl)))))
+
(defun org-dblock-write:gtimelog (params)
"Display day-by-day time reports in gtimelog format."
(let* ((ts (plist-get params :tstart))