summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Ebert <manuel.ebert@upf.edu>2012-05-24 18:14:12 +0200
committerManuel Ebert <manuel.ebert@upf.edu>2012-05-24 18:14:12 +0200
commit9a9a80cd8eca5244188352ad5d43bd79d7dbf00e (patch)
treee33054896a48bc06c73c3640dcc7d3f7bcdbf949
parent7b0829121fda70f6bdfdd900b4e52b8a79149870 (diff)
Fixes time parsing, closes #32
-rw-r--r--CHANGELOG.md1
-rw-r--r--jrnl/Journal.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index faa7d679..cf959904 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@ Changelog
### 0.2.4 (May 24, 2012)
+* [Fixed] Dates such as "May 3" will now be interpreted as being in the past if the current day is at least 28 days in the future
* [Fixed] Bug where composed entry is lost when the journal file fails to load
* [Changed] Changed directory structure and install scripts (removing the necessity to make an alias from `jrnl` to `jrnl.py`)
diff --git a/jrnl/Journal.py b/jrnl/Journal.py
index 3b0ccb6d..cf692109 100644
--- a/jrnl/Journal.py
+++ b/jrnl/Journal.py
@@ -241,6 +241,13 @@ class Journal:
else:
date = datetime(*date[:6])
+ # Ugly heuristic: if the date is more than 4 weeks in the future, we got the year wrong.
+ # Rather then this, we would like to see parsedatetime patched so we can tell it to prefer
+ # past dates
+ dt = datetime.now() - date
+ if dt.days < -28:
+ date = date.replace(date.year - 1)
+
return date
def new_entry(self, raw, date=None):