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

Sub-Issue of 2753: Add new Patterns to JabRef's Date class and write tests. #9307

Closed
ThiloteE opened this issue Oct 25, 2022 · 1 comment
Closed
Labels
bib(la)tex good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement

Comments

@ThiloteE
Copy link
Member

ThiloteE commented Oct 25, 2022

To solve this issue, one needs to add new Patterns to JabRef's Date class and write tests.

public class Date {
private static final DateTimeFormatter NORMALIZED_DATE_FORMATTER = DateTimeFormatter.ofPattern("uuuu[-MM][-dd]");
private static final DateTimeFormatter SIMPLE_DATE_FORMATS;
static {
List<String> formatStrings = Arrays.asList(
"uuuu-MM-dd'T'HH:mm[:ss][xxx][xx][X]", // covers 2018-10-03T07:24:14+03:00
"uuuu-MM-dd'T'HH:m[:ss][xxx][xx][X]", // covers 2018-10-03T17:2
"uuuu-MM-dd'T'H:mm[:ss][xxx][xx][X]", // covers 2018-10-03T7:24
"uuuu-MM-dd'T'H:m[:ss][xxx][xx][X]", // covers 2018-10-03T7:7
"uuuu-MM-dd'T'HH[:ss][xxx][xx][X]", // covers 2018-10-03T07
"uuuu-MM-dd'T'H[:ss][xxx][xx][X]", // covers 2018-10-03T7
"uuuu-M-d", // covers 2009-1-15
"uuuu-M", // covers 2009-11
"d-M-uuuu", // covers 15-1-2012
"M-uuuu", // covers 1-2012
"M/uuuu", // covers 9/2015 and 09/2015
"M/uu", // covers 9/15
"MMMM d, uuuu", // covers September 1, 2015
"MMMM, uuuu", // covers September, 2015
"d.M.uuuu", // covers 15.1.2015
"uuuu.M.d", // covers 2015.1.15
"uuuu", // covers 2015
"MMM, uuuu"); // covers Jan, 2020
SIMPLE_DATE_FORMATS = formatStrings.stream()
.map(DateTimeFormatter::ofPattern)
.reduce(new DateTimeFormatterBuilder(),
DateTimeFormatterBuilder::appendOptional,
(builder, formatterBuilder) -> builder.append(formatterBuilder.toFormatter()))
.toFormatter(Locale.US);
}

The order of the date patterns seem to matter as well, as I recently learned when extending the class to support Timestamps. The longest? pattern needs to come first.

See Section 2.3.9 of the biblatex manual http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf

Originally posted by @Siedlerchr in #2753 (comment)

@ThiloteE ThiloteE added good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement bib(la)tex labels Oct 25, 2022
@ThiloteE ThiloteE changed the title Sub-Issue of BibLaTeX date formats for parsing: Add new Patterns to JabRef's Date class and write tests. Sub-Issue of 2753: Add new Patterns to JabRef's Date class and write tests. Oct 25, 2022
@ThiloteE
Copy link
Member Author

closing, because outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bib(la)tex good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement
Projects
None yet
Development

No branches or pull requests

1 participant