Skip to content

Commit 4a63995

Browse files
Support AD and BC in year notations
1 parent 8551acc commit 4a63995

File tree

4 files changed

+88
-4
lines changed

4 files changed

+88
-4
lines changed

citeproc-java/src/main/java/de/undercouch/citeproc/csl/internal/rendering/SDatePart.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void renderInternal(RenderContext ctx) {
5555
switch (name) {
5656
case "year":
5757
if (date.length > 0) {
58-
value = renderYear(date[0]);
58+
value = renderYear(date[0], ctx);
5959
}
6060
break;
6161

@@ -77,7 +77,12 @@ private void renderInternal(RenderContext ctx) {
7777
}
7878
}
7979

80-
private String renderYear(int year) {
80+
private String renderYear(int year, RenderContext ctx) {
81+
if (year < 0) {
82+
return (-year) + ctx.getTerm("bc");
83+
} else if (year < 1000) {
84+
return year + ctx.getTerm("ad");
85+
}
8186
return String.valueOf(year);
8287
}
8388

citeproc-java/src/test/java/de/undercouch/citeproc/FixturesTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,9 @@ private String applyCiteprocJs(String mode, String style, ItemDataProvider itemD
810810
"condition_VariableNone",
811811
"date_Accessed",
812812
"date_AccessedCrash",
813-
// "date_DateAD",
814-
// "date_DateBC",
813+
"date_DateAD",
814+
"date_DateBC",
815+
// we don't render error messages
815816
// "date_DateNoDateNoTest",
816817
"date_DateNoDateWithTest",
817818
// "date_DayOrdinalDayOneOnly",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
mode: bibliography
2+
3+
style:
4+
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0">
5+
<locale>
6+
<terms>
7+
<term name="ad">AADD</term>
8+
<term name="bc">BBCC</term>
9+
</terms>
10+
</locale>
11+
<bibliography>
12+
<layout>
13+
<names variable="author" suffix=". ">
14+
<name initialize-with=". "/>
15+
</names>
16+
<text variable="title"/>
17+
<date form="text" variable="issued" date-parts="year-month-day" prefix=" (" suffix=")"/>
18+
</layout>
19+
</bibliography>
20+
</style>
21+
22+
items:
23+
- id: item1
24+
author:
25+
- given: Given
26+
family: Name
27+
title: My title
28+
issued:
29+
date-parts:
30+
- [-500]
31+
- id: item2
32+
author:
33+
- given: Given
34+
family: Name
35+
title: My title
36+
issued:
37+
date-parts:
38+
- [ 123 ]
39+
40+
result: |
41+
G. Name. My title (500BBCC)
42+
G. Name. My title (123AADD)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
mode: bibliography
2+
3+
style:
4+
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0">
5+
<bibliography>
6+
<layout>
7+
<names variable="author" suffix=". ">
8+
<name initialize-with=". "/>
9+
</names>
10+
<text variable="title"/>
11+
<date form="text" variable="issued" date-parts="year-month-day" prefix=" (" suffix=")"/>
12+
</layout>
13+
</bibliography>
14+
</style>
15+
16+
items:
17+
- id: item1
18+
author:
19+
- given: Given
20+
family: Name
21+
title: My title
22+
issued:
23+
date-parts:
24+
- [-500]
25+
- id: item2
26+
author:
27+
- given: Given
28+
family: Name
29+
title: My title
30+
issued:
31+
date-parts:
32+
- [ 123 ]
33+
34+
result: |
35+
G. Name. My title (500BC)
36+
G. Name. My title (123AD)

0 commit comments

Comments
 (0)