mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
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.
35 lines
No EOL
1.5 KiB
Gherkin
35 lines
No EOL
1.5 KiB
Gherkin
Feature: Reading and writing to journal with custom date formats
|
|
|
|
Scenario: Loading a sample journal
|
|
Given we use the config "little_endian_dates.yaml"
|
|
When we run "jrnl -n 2"
|
|
Then we should get no error
|
|
And the output should be
|
|
"""
|
|
09.06.2013 15:39 My first entry.
|
|
| Everything is alright
|
|
|
|
10.06.2013 15:40 Life is good.
|
|
| But I'm better.
|
|
"""
|
|
|
|
Scenario: Writing an entry from command line
|
|
Given we use the config "little_endian_dates.yaml"
|
|
When we run "jrnl 2013-07-12: A cold and stormy day. I ate crisps on the sofa."
|
|
Then we should see the message "Entry added"
|
|
When we run "jrnl -n 1"
|
|
Then the output should contain "12.07.2013 09:00 A cold and stormy day."
|
|
|
|
Scenario: Filtering for dates
|
|
Given we use the config "little_endian_dates.yaml"
|
|
When we run "jrnl -on 2013-06-10 --short"
|
|
Then the output should be "10.06.2013 15:40 Life is good."
|
|
When we run "jrnl -on 'june 6 2013' --short"
|
|
Then the output should be "10.06.2013 15:40 Life is good."
|
|
|
|
Scenario: Writing an entry at the prompt
|
|
Given we use the config "little_endian_dates.yaml"
|
|
When we run "jrnl" and enter "2013-05-10: I saw Elvis. He's alive."
|
|
Then we should get no error
|
|
And the journal should contain "[10.05.2013 09:00] I saw Elvis."
|
|
And the journal should contain "He's alive." |