-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
Conversation
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.
I'm out of the country right now, but should be back in a few days. v2.1 is
already in beta, and soon to be released, so it's too late for that one.
I haven't had a chance to look at this yet, but if all looks good, I don't
see why we can't bump it up into v2.1.1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯💯
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. |
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.