-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add support for date ranges for BibLaTeX Date #14289
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
base: main
Are you sure you want to change the base?
Conversation
Hey @Alex1034!Thank you for contributing to JabRef! Your help is truly appreciated ❤️. We have automatic checks in place, based on which you will soon get automated feedback if any of them are failing. We also use TragBot with custom rules that scans your changes and provides some preliminary comments, before a maintainer takes a look. TragBot is still learning, and may not always be accurate. In the "Files changed" tab, you can go through its comments and just click on "Resolve conversation" if you are sure that it is incorrect, or comment on the conversation if you are doubtful. Please re-check our contribution guide in case of any other doubts related to our contribution workflow. |
| @Override | ||
| public TemporalAccessor fromString(String string) { | ||
| if (StringUtil.isNotBlank(string)) { | ||
| // ✅ Sanitize incomplete ranges (e.g., "2010/" → "2010") |
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.
remove this AI comment
koppor
left a comment
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.
- Tests are missing
- CHANGELOG.md entry missing
|
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
| private String sanitizeIncompleteRange(String dateString) { | ||
| String trimmed = dateString.trim(); | ||
|
|
||
| if (trimmed.endsWith("/") && !trimmed.matches(".*\\d+/\\d+.*")) { | ||
| LOGGER.debug("Sanitizing incomplete range (trailing slash): {}", trimmed); | ||
| return trimmed.substring(0, trimmed.length() - 1).trim(); | ||
| } | ||
|
|
||
| if (trimmed.startsWith("/") && !trimmed.matches(".*\\d+/\\d+.*")) { | ||
| LOGGER.debug("Sanitizing incomplete range (leading slash): {}", trimmed); | ||
| return trimmed.substring(1).trim(); | ||
| } | ||
|
|
||
| return dateString; |
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 is more a logic part, not a gui part. Please search for an appropriate place in the logic package.
I would assume near org.jabref.model.entry.Date
| private DateEditorViewModel viewModel; | ||
| private StringConverter<TemporalAccessor> dateToStringConverter; | ||
|
|
||
| private TemporalAccessor sentinel() { |
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 is more a constant. Also needs to have a comment.
|
Your code currently does not meet JabRef's code guidelines. IntelliJ auto format covers some cases. There seem to be issues with your code style and autoformat configuration. Please reformat your code (Ctrl+Alt+L) and commit, then push. In special cases, consider using |
|
JUnit tests of You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide. |
|
You have removed the "Mandatory Checks" section from your pull request description. Please adhere to our pull request template. |
|
You ticked that you modified If you made changes that are visible to the user, please add a brief description along with the issue number to the |
Closes #8902
Summary
This pull request adds support for date ranges in BibLaTeX date fields.
Previously, JabRef only supported single dates (e.g.,
2021-05-03).With this change, JabRef now correctly parses and formats date ranges (e.g.,
2020/2021,2015-01-01/2016-12-31) in compliance with ISO 690 and BibLaTeX standards.Steps to test
2020/20212021-05-01/2021-06-30date = {2020/2021}.Additional details
Date.javato normalize and handle start/end dates.DateEditorViewModel.javato correctly format and display date ranges."2010/" → "2010").CHANGELOG.mdunder the [Unreleased] section.Changelog
CHANGELOG.mdappropriately.PR Checklist