Fix handling of little-endian date format

Ever since version 2.0, when parsing a journal file, jrnl would not use
the custom date format string anymore. Instead, it relied on the
dateutil library to get the parsing right. This change was made to allow
people to change their date format without having to manually change
their file. However, this broke some existing date formats like
%d.%m.%Y, as it would falsely interpret the month as day and vice versa.
This commit adds some tests to catch this error and fixes it by trying
to parse the dates using the custom format first, only falling back to
dateutil when needed.
This commit is contained in:
Peter Schmidbauer 2019-10-26 21:43:48 +02:00
parent 9d8d6a83ae
commit 7f46d1a40a
7 changed files with 92 additions and 1 deletions

View file

@ -21,3 +21,14 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x
"""
Then the output should contain "Password"
and the output should contain "2013-06-10 15:40 Life is good"
Scenario: Upgrade and parse journals with little endian date format
Given we use the config "upgrade_from_195_little_endian_dates.json"
When we run "jrnl -9" and enter "Y"
Then the output should contain
"""
10.06.2010 15:00 A life without chocolate is like a bad analogy.
10.06.2013 15:40 He said "[this] is the best time to be alive".
"""
Then the journal should have 2 entries