# Australian date range format without babel in biblatex?

I want Australian style dates and date ranges used in my biblatex style (biblatex-sbl) even when babel or polyglossia are not loaded. The following code fails for cases when the range lies within a month. I want “1–5 January 2016”, but instead I get “1 January–52016”. Can anyone please help? (FWIW, biblatex-chicago also fails in this situation.)

\documentclass{article}
\usepackage[backend=biber,dateabbrev=false]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{a,
title = {TitleA},
date = {2016-01-02}
}
@book{b,
title = {TitleB},
date = {2016-01-02/2016-02-05}
}
@book{c,
title = {TitleC},
date = {2016-01-01/2016-01-05}
}
\end{filecontents}
\DefineBibliographyExtras{english}{%
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%
}
\begin{document}
\cite{a}, \cite{b}, \cite{c}
\printbibliography
\end{document}

• Did you try: \usepackage[backend=biber,dateabbrev=false,language=australian]{biblatex}? – Ross Nov 18 '16 at 3:25
• @Ross, what side affects will this have? I only want dates to change. and I do want babel in general to control date formats for languages other than English if the end user wants. – David Purton Nov 18 '16 at 3:33
• Sorry, but that question is too open ended and does not have an answer. I read your question as fixing the date, which is done by providing the language key, but it looks like you have other things going on. – Ross Nov 18 '16 at 4:05

Ah - got it. I need this:

\DefineBibliographyExtras{english}{%
\restorecommand\mkdaterangecomp
\restorecommand\mkdaterangecompextra
\restorecommand\mkdaterangeterse
\restorecommand\mkdaterangeterseextra
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%
}


Edit

Actually, the above is not sufficient. For the sake of providing a proper answer for this question, I actually needed the following. This also takes into account biblatex's extended date/time features.

\DefineBibliographyExtras{english}{%
\protected\def\mkdaterangecomp{%
\mkdaterangetrunc{long}}%
\protected\def\mkdaterangeterse{%
\mkdaterangetrunc{short}}%
\protected\def\mkdaterangecompextra{%
\mkdaterangetruncextra{long}}%
\protected\def\mkdaterangeterseextra{%
\mkdaterangetruncextra{short}}%
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\thefield{#3}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}
{\bibstring{\thefield{#1}}}
{\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}%
}


There's a simple approach (tested with xelatex and pdflatex)...

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{a,
title = {TitleA},
date = {2016-01-02}
}
@book{b,
title = {TitleB},
date = {2016-01-02/2016-02-05}
}
@book{c,
title = {TitleC},
date = {2016-01-01/2016-01-05}
}
\end{filecontents}

\usepackage[australian]{babel}

% Polyglossia variants don't quite work with biblatex at the moment
%\usepackage{polyglossia}
%\setdefaultlanguage[variant=british]{english}

\usepackage[%
%
% Basics
%
style=authoryear,
alldates=long,
dateabbrev=false,
%alldates=ymd, % ISO like, but customizable format (Recommended)
%
% Unecessary to set
%
% [default] autobib=try to get main document
% language from babel/polyglossia
%language=autobib,
%
% Other (new) settings you might like to play with
%
%  alldatesusetime=true,
%  alltimes=24h,
%  seconds=true,
%  timezones=true,
%  datezeros=true,
%  dateera=secular,
%  datecirca=true,
%  dateuncertain=true,
]{biblatex}

\begin{document}

Current language: \currentlang\\

\autocite{a}\\
\autocite{b}\\
\autocite{c}\\

\printbibliography
\end{document}


That yields, in the bibliography/references section:

TitleA (2 January 2016).
TitleB (2 January 2016-5 February 2016).
TitleC (1 January 2016-5 January 2016).

In summary you:

• Set australian as your babel variant \usepackage[australian]{babel}
• Use the biblatex option alldates=long
• Set other options as desired (you've chosen dateabbrev=false).

This gives you "1 January 2016-5 January 2016" rather than "1–5 January 2016". But I'd suggest the former is better given that a date range like "31 December 2016-5 January 2016" will have no compressed and readable equivalent of the sort you've specified.

This also appears to give you what you want in terms of what you expressed responding to @Ross.

Biblatex support for Polyglossia is currently a problem (specifically for polyglossia language variant setting). The solution is to use babel, not polyglossia, for the moment. For details see http://tex.stackexchange.com > How do we get Polyglossia language variants to work with Biblatex bibliographies?.

However, I'd commend to you alldates=ymd which gives you an ISO like format (but with customization options that ISO doesn't permit). In the internet age it's right to make your dates globally friendly. In that case, when using alldates=ymd, the command \usepackage[australian]{babel} becomes irrelevant and could be removed (for biblatex purposes). That'll produce:

TitleA (2016-01-02).
TitleB (2016-01-02/2016-02-05).
TitleC (2016-01-01/2016-01-05).

A warning that Biblatex has recently introduced a raft of datetime features to support EDTF for inputting dates (e.g. 2016-07-22T22:12+10:00; 2016?; 1875~; -0379~). Although the released biblatex is fairly robust this is still undergoing testing (I'd at least ensure your latex packages are up to date).

• Using the australian option, of course, will turn the entire document Australian; that might not be intended (though I suppose the differences to British are minute; but there could be quite some differences to American). – moewe Nov 22 '16 at 9:40
• While I have some liking for the YYYY-MM-DD date format, it still looks odd and a bit awkward in many context where you want real people to read the date. (Yes ISO says it's the right thing, and technically in Germany it's the norm, but frankly no-one uses it.) – moewe Nov 22 '16 at 9:42
• I also don't think it's appropriate for a biblatex style to hard code a babel language. In my case I want my style to match the SBL handbook of style when no babel language is loaded and allow end users to modify it by loading a language if they so desire. In the end it's such an edge case that it will likely never appear in real life. I just didn't want it giving bogus output like it originally was. – David Purton Nov 22 '16 at 11:28
• @moewe and @davidpurton. Well with your (David's) answer (hard coding date format), Ross's (biblatex option language=australian), and mine \usepackage[australian]{babel} there are three options if we take your (David's) question more generally than your current edge case. @moewe, Yes do I accept there could well be reasons for choosing a colloquial format. I think it is right that biblatex supports colloquial formats in addition to ISO/EDTF type formats so individual users and authors can decide for themselves. – John Bentley Nov 23 '16 at 7:19