Skip to content

Commit

Permalink
Improve mergedate minimum and basic (plk#520)
Browse files Browse the repository at this point in the history
Detect if \printlabeldateextra and \printdate have the same level of
precision. Previously the detection was hard-coded assuming
year-only precision for labeldate and full precision for date.
  • Loading branch information
moewew committed Oct 24, 2017
1 parent 195be70 commit 5c08d06
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
45 changes: 28 additions & 17 deletions tex/latex/biblatex/bbx/authoryear.bbx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,29 @@
\newcommand*{\iflabeldateisdate}{%
\ifboolexpr{%
not test {\iffieldundef{labeldatesource}}
and
(test {\iffieldequalstr{labeldatesource}{}}
and
(test {\iffieldequalstr{labeldatesource}{}}
or test {\iffieldequalstr{labeldatesource}{year}})}}

\newcommand*{\ifdatehasyearonlyprecision}[1]{%
\ifboolexpr{test {\ifcsstring{blx@dateformat@#1date}{year}}
or (test {\iffieldundef{#1month}}
and test {\iffieldundef{#1season}})}}

\newcommand*{\ifdatehastime}[1]{%
\ifboolexpr{togl {blx@#1dateusetime}
and not test {\iffieldundef{#1hour}}}}

\newcommand*{\ifdateshavedifferentprecision}[2]{%
\ifboolexpr{ (test {\ifdatehasyearonlyprecision{#1}}
and not test {\ifdatehasyearonlyprecision{#2}})
or (not test {\ifdatehasyearonlyprecision{#1}}
and test {\ifdatehasyearonlyprecision{#2}})
or (test {\ifdatehastime{#1}}
and not test {\ifdatehastime{#2}})
or (not test {\ifdatehastime{#1}}
and test {\ifdatehastime{#2}})}}

\def\bbx@opt@mergedate@true{\bbx@opt@mergedate@compact}

% merge date/issue with date label
Expand Down Expand Up @@ -86,21 +105,17 @@
\ifboolexpr{
test {\iflabeldateisdate}
and
test {\iffieldundef{season}}
and
test {\iffieldundef{month}}
not test {\ifdateshavedifferentprecision{label}{}}
}
{}
{\printdate}}%
\renewbibmacro*{issue+date}{%
\ifboolexpr{
test {\iflabeldateisdate}
and
test {\iffieldundef{issue}}
and
test {\iffieldundef{season}}
not test {\ifdateshavedifferentprecision{label}{}}
and
test {\iffieldundef{month}}
test {\iffieldundef{issue}}
}
{}
{\printtext[parens]{%
Expand All @@ -119,9 +134,7 @@
\ifboolexpr{
test {\iflabeldateisdate}
and
test {\iffieldundef{season}}
and
test {\iffieldundef{month}}
not test {\ifdateshavedifferentprecision{label}{}}
and
test {\iffieldundef{extrayear}}
}
Expand All @@ -131,13 +144,11 @@
\ifboolexpr{
test {\iflabeldateisdate}
and
test {\iffieldundef{issue}}
and
test {\iffieldundef{season}}
and
test {\iffieldundef{month}}
not test {\ifdateshavedifferentprecision{label}{}}
and
test {\iffieldundef{extrayear}}
and
test {\iffieldundef{issue}}
}
{}
{\printtext[parens]{%
Expand Down
24 changes: 20 additions & 4 deletions tex/latex/biblatex/biblatex.sty
Original file line number Diff line number Diff line change
Expand Up @@ -5179,12 +5179,20 @@
\dateeraprint{#2endyear}}}}}}}
\newrobustcmd*{\mkdaterangeyear}[1]{%
\blx@imc@clearfield{#1season}%
\blx@imc@clearfield{#1month}%
\blx@imc@clearfield{#1day}%
\blx@imc@clearfield{#1season}%
\blx@imc@clearfield{#1hour}%
\blx@imc@clearfield{#1minute}%
\blx@imc@clearfield{#1second}%
\blx@imc@clearfield{#1timezone}%
\blx@imc@clearfield{#1endseason}%
\blx@imc@clearfield{#1endmonth}%
\blx@imc@clearfield{#1endday}%
\blx@imc@clearfield{#1endseason}%
\blx@imc@clearfield{#1endhour}%
\blx@imc@clearfield{#1endminute}%
\blx@imc@clearfield{#1endsecond}%
\blx@imc@clearfield{#1endtimezone}%
\iffieldsequal{#1year}{#1endyear}
{\blx@imc@clearfield{#1endyear}}
{}%
Expand Down Expand Up @@ -5259,12 +5267,20 @@
\iffieldundef{#2#3day}{}{\bibdatesep\mkdayzeros{\thefield{#2#3day}}}}
\newrobustcmd*{\mkdaterangeyearextra}[1]{%
\blx@imc@clearfield{#1season}%
\blx@imc@clearfield{#1month}%
\blx@imc@clearfield{#1day}%
\blx@imc@clearfield{#1season}%
\blx@imc@clearfield{#1hour}%
\blx@imc@clearfield{#1minute}%
\blx@imc@clearfield{#1second}%
\blx@imc@clearfield{#1timezone}%
\blx@imc@clearfield{#1endseason}%
\blx@imc@clearfield{#1endmonth}%
\blx@imc@clearfield{#1endday}%
\blx@imc@clearfield{#1endseason}%
\blx@imc@clearfield{#1endhour}%
\blx@imc@clearfield{#1endminute}%
\blx@imc@clearfield{#1endsecond}%
\blx@imc@clearfield{#1endtimezone}%
\iffieldsequal{#1year}{#1endyear}
{\blx@imc@clearfield{#1endyear}}
{}%
Expand Down

0 comments on commit 5c08d06

Please # to comment.