-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix: fallback conversion from BibTeX year field to biblatex date field #13040
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?
Fix: fallback conversion from BibTeX year field to biblatex date field #13040
Conversation
…dates in BibTeX `year` field
return changes; | ||
} | ||
|
||
private Collection<? extends FieldChange> applyDateFallback(BibEntry entry) { |
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.
The method applyDateFallback is new and should follow the Single-responsibility principle. It currently handles both date parsing and field clearing, which could be separated.
String yearText = yearValue.get().trim(); | ||
Optional<Date> fallbackDate = Date.parse(yearText); | ||
if (fallbackDate.isPresent()) { | ||
entry.setField(StandardField.DATE, yearText).ifPresent(changes::add); |
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.
The method applyDateFallback should use withField instead of setField when creating a new BibEntry object to adhere to JabRef's coding standards.
…dates in BibTeX `year` field
…onvert-to-biblatex
@trag-bot didn't find any issues in the code! ✅✨ |
Closes #11868
This PR introduces a fallback mechanism in the "Convert to biblatex" cleanup step to improve compatibility with BibLaTeX-style date formats mistakenly entered in the BibTeX year field.
What was the problem?
Users reported that when year = {2011-11-11} (or other extended formats) is used in BibTeX mode, the "Convert to biblatex" cleanup did not populate the date field as expected.
This is because the cleanup logic only merges year + month if both are present and parsable. Non-standard values in year were silently ignored.
What has been changed?
This fallback is intentionally conservative and only runs if the standard cleanup logic does not produce a date.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)