summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-11 19:14:23 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-11 19:14:23 -0400
commit1a030da55d5b16d18261f029cddb543e3ef32424 (patch)
treecfd273fcbaa059fa56311ae22599a205a2b1d4fd /src/times.cc
parent4eb46bedf0e6e31797826d05992e007f21ee830b (diff)
downloadfork-ledger-1a030da55d5b16d18261f029cddb543e3ef32424.tar.gz
fork-ledger-1a030da55d5b16d18261f029cddb543e3ef32424.tar.bz2
fork-ledger-1a030da55d5b16d18261f029cddb543e3ef32424.zip
Rewrote the "entry" command. It's ALIVE!
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/times.cc b/src/times.cc
index fe4d2b53..53be925f 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -82,14 +82,22 @@ namespace {
result.tm_min = 0;
result.tm_sec = 0;
- if (result.tm_year == -1)
- result.tm_year = (year == -1 ? int(CURRENT_DATE().year()) : year) - 1900;
+ if (result.tm_mday == -1)
+ result.tm_mday = 1;
- if (result.tm_mon == -1)
+ if (result.tm_mon == -1) {
result.tm_mon = 0;
- if (result.tm_mday == -1)
- result.tm_mday = 1;
+ if (result.tm_mday > (CURRENT_DATE().day() - 1))
+ result.tm_mon = 11;
+ }
+
+ if (result.tm_year == -1) {
+ result.tm_year = (year == -1 ? int(CURRENT_DATE().year()) : year) - 1900;
+
+ if (result.tm_mon > (CURRENT_DATE().month() - 1))
+ result.tm_year--;
+ }
return true;
}