Permalink
Browse files

Wrote binder-time-range

  • Loading branch information...
1 parent f054b4b commit 6ba162cf67fb7a03348d8a6663910ba88eb9a3e3 @jwiegley committed Dec 13, 2007
Showing with 16 additions and 11 deletions.
  1. +16 −11 core/ledger.lisp
View
@@ -72,21 +72,26 @@
(values binder args))))
+(defun binder-time-range (&optional binder)
+ (let ((binder (or binder *last-binder*))
+ earliest latest)
+ (iterate ((xact (scan-transactions binder)))
+ (if (or (null earliest)
+ (local-time< (xact-date xact) earliest))
+ (setf earliest (xact-date xact)))
+ (if (or (null latest)
+ (local-time> (xact-date xact) latest))
+ (setf latest (xact-date xact))))
+ (time-range :begin earliest :end latest :end-inclusive-p t)))
+
(defun binder-statistics (&optional binder)
(let ((binder (or binder *last-binder*)))
(format t "~&Binder statistics:~%")
- (let (earliest latest)
- (iterate ((xact (scan-transactions binder)))
- (if (or (null earliest)
- (local-time< (xact-date xact) earliest))
- (setf earliest (xact-date xact)))
- (if (or (null latest)
- (local-time> (xact-date xact) latest))
- (setf latest (xact-date xact))))
- (format t "~12@A earliest date~%" (strftime earliest))
- (format t "~12@A latest date~%" (strftime latest))
+ (let ((range (binder-time-range binder)))
+ (format t "~12@A earliest date~%" (strftime (time-range-begin range)))
+ (format t "~12@A latest date~%" (strftime (time-range-end range)))
(format t "~12D days covered (approx.)~%"
- (round (duration-seconds (time-difference earliest latest))
+ (round (duration-seconds (time-range-duration range))
86400)))
(format t "~12D transactions~%"
(collect-length (scan-transactions binder)))

0 comments on commit 6ba162c

Please sign in to comment.