| 1 |
% |
| 2 |
% This file demonstrates various date formats and tests which apply to them |
| 3 |
% for output |
| 4 |
% |
| 5 |
\documentclass[a4paper]{article} |
| 6 |
\usepackage{fontspec} |
| 7 |
\usepackage[american]{babel} |
| 8 |
\usepackage{csquotes} |
| 9 |
\begin{filecontents}[force]{\jobname.bib} |
| 10 |
@misc{date1, |
| 11 |
note = {Years with implicit era}, |
| 12 |
author = {Author1}, |
| 13 |
date = {-0099-07-11/-0043-03-13}, % Negative date range |
| 14 |
origdate = {-0477}, % Negative date |
| 15 |
eventdate = {0477/0566}, % Forced CE era due to dateeraauto setting |
| 16 |
urldate = {-0020/0100}, % Cross BCE/CE range |
| 17 |
} |
| 18 |
@misc{date2, |
| 19 |
note = {Dates with circa and uncertain markers}, |
| 20 |
author = {Author2}, |
| 21 |
date = {1723%}, % year with ISO8601-2 approximate (circa) and uncertainty markers |
| 22 |
origdate = {1934-02~}, % year and month with circa marker |
| 23 |
eventdate = {1976?}, % year with uncertainty marker |
| 24 |
urldate = {1922~}, % year with ISO8601-2 approximate (circa) marker |
| 25 |
} |
| 26 |
@misc{date3, |
| 27 |
note = {Date ranges}, |
| 28 |
author = {Author3}, |
| 29 |
date = {1934~/1936~}, % year range with circa markers |
| 30 |
origdate = {1723~/..}, % open-ended year range with circa marker |
| 31 |
eventdate = {1976?/..}, % open-ended year range with uncertainty marker |
| 32 |
urldate = {1976/..} % open-ended year range with open marker |
| 33 |
} |
| 34 |
@misc{date4, |
| 35 |
note = {Times}, |
| 36 |
author = {Author4}, |
| 37 |
date = {2004-04-25T14:34:00/2004-04-25T14:37:06}, % Date with time, floating timezone |
| 38 |
origdate = {2004-04-25T14:34:00Z/2004-04-25T14:34:05Z}, % Date with time, UTC timezone |
| 39 |
eventdate = {2004-04-25T14:34:00+05:00/2004-04-25T15:34:00+05:00}, % Date with time, explicit timezone |
| 40 |
urldate = {2004-04-25T14:34:00/2004-04-25T15:00:00}, % Datetime range |
| 41 |
} |
| 42 |
@misc{date5, |
| 43 |
note = {Seasons}, |
| 44 |
author = {Author5}, |
| 45 |
date = {1723-21}, % year divisions (21=spring) |
| 46 |
origdate = {1934-24~}, % uncertain year plus season |
| 47 |
eventdate = {1934-22/1934-23}, % range with seasons |
| 48 |
} |
| 49 |
@misc{date6, |
| 50 |
% uses the 'nodate' localisation string due to default \DeclareLabeldate setting |
| 51 |
note = {Date from literal/localisation string}, |
| 52 |
author = {Author6}, |
| 53 |
} |
| 54 |
@misc{date7, |
| 55 |
note = {Unspecified dates can be used to do amusing things}, |
| 56 |
author = {Author7}, |
| 57 |
date = {19XX}, % unspecified year in century |
| 58 |
origdate = {199X}, % unspecified year in decade |
| 59 |
} |
| 60 |
@misc{date8, |
| 61 |
note = {Astronomical year era}, |
| 62 |
author = {Author8}, |
| 63 |
date = {0001}, % with dateera=astronomical, 1, otherwise 1 CE |
| 64 |
origdate = {0000}, % with dateera=astronomical, 0, otherwise 1 BCE |
| 65 |
eventdate = {-0001}, % with dateera=astronomical, -1, otherwise 2 BCE |
| 66 |
urldate = {-0379} % with dateera=astronomical, -379, otherwise 380 BCE |
| 67 |
} |
| 68 |
@misc{date9, |
| 69 |
note = {Automatic era setting}, |
| 70 |
author = {Author9}, |
| 71 |
date = {1066}, |
| 72 |
origdate = {0876}, |
| 73 |
eventdate = {0402}, |
| 74 |
urldate = {-0382} |
| 75 |
} |
| 76 |
@misc{date10, |
| 77 |
note = {More Date ranges}, |
| 78 |
author = {Author10}, |
| 79 |
date = {1034/}, % unknown |
| 80 |
origdate = {/1034}, % unknown |
| 81 |
eventdate = {../1034}, % open-start to year range |
| 82 |
urldate = {../1034} % open |
| 83 |
} |
| 84 |
\end{filecontents} |
| 85 |
\usepackage[style=authoryear,% |
| 86 |
% dateabbrev=false,% when false, don't abbreviate months/year divisions |
| 87 |
% julian=true,% convert dates before gregorianstart to Julian Calendar |
| 88 |
% gregorianstart=1582-10-15,% Default |
| 89 |
alldates=short,% |
| 90 |
% alldates=ymd,% Year-Month-Day format |
| 91 |
% alldates=iso,% ISO8601 format |
| 92 |
alldatesusetime=true, % print time components in non-compact date ranges |
| 93 |
alltimes=12h,% |
| 94 |
% alltimes=24h,% prints 24 hour format times (default) |
| 95 |
% alltimes=24hcomp,% prints 24 hour compressed format times |
| 96 |
% seconds=true,% uncomment to print seconds |
| 97 |
% timezones=true,% uncomment to print timezones |
| 98 |
datezeros=false,% pad date components with zeros? |
| 99 |
dateera=secular,% prints BCE/CE controlled by dateerauto, datezeros |
| 100 |
% dateera=christian,% prints BC/AD controlled by dateerauto, datezeros |
| 101 |
% dateera=astronomical,% prints astronomical dates, controlled by datezeros |
| 102 |
dateeraauto=600,% Sets the max year ceiling for automatic printing of era |
| 103 |
% abbreviate=false,% prints full date localisation strings |
| 104 |
dateuncertain=true,% |
| 105 |
datecirca=true,% |
| 106 |
sorting=none,% |
| 107 |
backend=biber]{biblatex} |
| 108 |
\addbibresource{\jobname.bib} |
| 109 |
|
| 110 |
\defbibenvironment{simple} |
| 111 |
{\list{} |
| 112 |
{\setlength{\leftmargin}{0pt}% |
| 113 |
\setlength{\itemindent}{0pt}% |
| 114 |
\setlength{\bibitemsep}{1ex}% |
| 115 |
\setlength{\itemsep}{\bibitemsep}% |
| 116 |
\setlength{\parsep}{\bibparsep}}} |
| 117 |
{\endlist} |
| 118 |
{\item} |
| 119 |
|
| 120 |
\DeclareFieldFormat{urldate}{#1} |
| 121 |
\DeclareFieldFormat{time}{\mkbibemph{#1}} |
| 122 |
\DeclareFieldFormat{labeltime}{\mkbibemph{#1}} |
| 123 |
\DeclareFieldFormat{origtime}{\mkbibemph{#1}} |
| 124 |
\DeclareFieldFormat{eventtime}{\mkbibemph{#1}} |
| 125 |
\DeclareFieldFormat{urltime}{\mkbibemph{#1}} |
| 126 |
|
| 127 |
\makeatletter |
| 128 |
|
| 129 |
\DeclareBibliographyDriver{misc}{% |
| 130 |
\printfield[emph]{note}\\ |
| 131 |
\iffieldundef{labelyear}{}{% |
| 132 |
\printtext[bold]{labeldate = }\printlabeldate |
| 133 |
\iffieldundef{labelhour}{} |
| 134 |
{\\\printtext[bold]{labeltime = }\printlabeltime}}\\% |
| 135 |
\iffieldundef{year}{}{% |
| 136 |
\iffieldequalstr{dateunspecified}{yearincentury} |
| 137 |
{\printtext[bold]{date = }\number\numexpr\thefield{year}/100+1\relax th Century} |
| 138 |
{\printtext[bold]{date = }\printdate |
| 139 |
\iffieldundef{hour}{} |
| 140 |
{\\\printtext[bold]{time = }\printtime}}}\\% |
| 141 |
\iffieldundef{origyear}{}{% |
| 142 |
\iffieldequalstr{origdateunspecified}{yearindecade} |
| 143 |
{\printtext[bold]{date = }The \expandafter\@gobbletwo\number\thefield{origyear}s} |
| 144 |
{\printtext[bold]{origdate = }\printorigdate |
| 145 |
\iffieldundef{orighour}{} |
| 146 |
{\\\printtext[bold]{origtime = }\printorigtime}}}\\% |
| 147 |
\iffieldundef{eventyear}{}{% |
| 148 |
\printtext[bold]{eventdate = }\printeventdate |
| 149 |
\iffieldundef{eventhour}{} |
| 150 |
{\\\printtext[bold]{eventtime = }\printeventtime}}\\% |
| 151 |
\iffieldundef{urlyear}{}{% |
| 152 |
\printtext[bold]{urldate = }\printurldate |
| 153 |
\iffieldundef{urlhour}{} |
| 154 |
{\\\printtext[bold]{urltime = }\printurltime}}% |
| 155 |
} |
| 156 |
|
| 157 |
\begin{document} |
| 158 |
\section*{Date formats} |
| 159 |
This example file parses and formats some of the supported date formats and |
| 160 |
demonstrates the output options. See the source for details. You can change |
| 161 |
the options in the source file and this document will show you the options chosen. |
| 162 |
\subsection*{Options used to format this test document} |
| 163 |
\begingroup |
| 164 |
datecirca=\textbf{\iftoggle{blx@datecirca}{1}{0}}\\ |
| 165 |
dateuncertain=\textbf{\iftoggle{blx@dateuncertain}{1}{0}}\\ |
| 166 |
dateera=\textbf{\blx@dateera}\\ |
| 167 |
dateerauto=\textbf{\blx@dateeraauto}\\ |
| 168 |
datezeros=\textbf{\iftoggle{blx@datezeros}{1}{0}}\\ |
| 169 |
timezeros=\textbf{\iftoggle{blx@timezeros}{1}{0}}\\ |
| 170 |
timezones=\textbf{\iftoggle{blx@timezones}{1}{0}}\\ |
| 171 |
seconds=\textbf{\iftoggle{blx@seconds}{1}{0}}\\ |
| 172 |
julian=\textbf{\iftoggle{blx@julian}{1}{0}}\\ |
| 173 |
gregorianstart=\textbf{\blx@gregorianstart}\\ |
| 174 |
\def\do#1{% |
| 175 |
#1=\textbf{\csuse{blx@dateformat@#1}}\\} |
| 176 |
\do{labeldate} |
| 177 |
\abx@dodates |
| 178 |
\def\do#1{% |
| 179 |
#1time=\textbf{\csuse{blx@timeformat@#1time}}\\ |
| 180 |
#1dateusetime=\textbf{\iftoggle{blx@#1dateusetime}{1}{0}}\\} |
| 181 |
\do{label} |
| 182 |
\abx@dodatetypes |
| 183 |
\endgroup |
| 184 |
\subsection*{Example Citation Formats} |
| 185 |
\textcite{date1,date2,date3,date4,date5,date6,date7,date8,date9,date10}\\[1ex] |
| 186 |
\cite{date1}\\ |
| 187 |
\cite{date2}\\ |
| 188 |
\cite{date3}\\ |
| 189 |
\cite{date4}\\ |
| 190 |
\cite{date5}\\ |
| 191 |
\cite{date6}\\ |
| 192 |
\cite{date7}\\ |
| 193 |
\cite{date8}\\ |
| 194 |
\cite{date9}\\ |
| 195 |
\cite{date10} |
| 196 |
\printbibliography[env=simple,title={Example Bibliography Formats}] |
| 197 |
\end{document} |