Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing Journals using a little-endian date format #694

Merged
merged 2 commits into from Nov 12, 2019

Conversation

pspeter
Copy link
Contributor

@pspeter pspeter commented Oct 26, 2019

Fixes parts of #630 and one source of failure during upgrading to 2.0 (#664).

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 (when %d <= 12). This commit adds some tests using the little endian date format and fixes the behavior by trying to parse the dates using the custom format first, only falling back to dateutil when needed.

Note that this does not yet allow users to make new entries using the little endian format yet. It will still use the dateutil parser for this. As I usually create new entries with no timestamp or just "today" or "yesterday" as date, this is an okay trade-off for me, but still not ideal. At least upgrading and querying works again properly this way.

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.
@pspeter pspeter changed the title Fix handling of little-endian date format Fix parsing Journals using a little-endian date format Oct 26, 2019
@wren wren added this to the v2.1.2 - Non-critical bug fixes milestone Oct 28, 2019
@wren wren added bug Something isn't working 📌 This can't go stale labels Oct 28, 2019
@pspeter
Copy link
Contributor Author

pspeter commented Nov 1, 2019

@wren Any chance we could see this in a 2.0.2 (or 2.1) release? This is blocking me from really using jrnl at the moment along with #699. I know you have some milestones planned out already but in my opinion hot-fixes should get released quicker if someone is willing to put in the work.

@wren
Copy link
Member

wren commented Nov 4, 2019 via email

micahellison
micahellison previously approved these changes Nov 12, 2019
Copy link
Member

@micahellison micahellison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Member

@micahellison micahellison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯💯

@micahellison micahellison merged commit 4302cf2 into jrnl-org:master Nov 12, 2019
@pspeter pspeter deleted the fix-custom-dates branch November 19, 2019 10:05
@lock
Copy link

lock bot commented May 21, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the 🔒 Outdated label May 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working 🔒 Outdated 📌 This can't go stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants