summaryrefslogtreecommitdiff
path: root/src/post.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-02-04 19:48:11 -0500
committerJohn Wiegley <johnw@newartisans.com>2010-02-05 00:00:40 -0500
commit313c88a6566dd3aee78069125925c867ae24e871 (patch)
tree798d040811e9cfc0f51ad822c4369f5252bd9fc0 /src/post.h
parent6870c54644ba41fe360d43d27885ded46beac7c5 (diff)
downloadfork-ledger-313c88a6566dd3aee78069125925c867ae24e871.tar.gz
fork-ledger-313c88a6566dd3aee78069125925c867ae24e871.tar.bz2
fork-ledger-313c88a6566dd3aee78069125925c867ae24e871.zip
Added post_t::compare_by_date_and_sequence comparator
Diffstat (limited to 'src/post.h')
-rw-r--r--src/post.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/post.h b/src/post.h
index cea1aca1..3a8c5541 100644
--- a/src/post.h
+++ b/src/post.h
@@ -199,6 +199,20 @@ public:
friend class xact_t;
+ struct compare_by_date_and_sequence
+ {
+ bool operator()(const post_t * left, const post_t * right) const {
+ gregorian::date_duration duration =
+ left->actual_date() - right->actual_date();
+ if (duration.days() == 0) {
+ return ((left->pos ? left->pos->sequence : 0) <
+ (right->pos ? right->pos->sequence : 0));
+ } else {
+ return duration.days() < 0;
+ }
+ }
+ };
+
#if defined(HAVE_BOOST_SERIALIZATION)
private:
/** Serialization. */