具有日期范围的 biblatex eventdate 的自定义格式

具有日期范围的 biblatex eventdate 的自定义格式

eventdate如果指定了几天或几周的范围,如何在 biblatex 中指定自定义日期格式?

例如,使用\thefield{eventday}仅返回范围的第一天,但​​不返回最后一天。我尝试过这种方式:

\documentclass{article}

\usepackage[style=numeric,backend=biber]{biblatex}

\DeclareFieldFormat{eventdate}{%
  \thefield{eventyear}%
  \space
  \mkbibmonth{\thefield{eventmonth}}%
  \space%
  \thefield{eventday}}

\begin{filecontents*}{database.bib}
@inproceedings{Baker2011,
 author = {Baker, Christopher R. and Dolan, John M. and Wang, Shige and Litkouhi, Bakhtiar B.},
 bookpagination = {page},
 booktitle = {2011 IEEE Int. Conf. Robotics and Automation},
 doi = {10.1109/ICRA.2011.5980355},
 eventdate = {2011-05-09/2011-05-13},
 eventtitle = {2011 IEEE International Conference on Robotics and Automation (ICRA 2011)},
 isbn = {978-1-61284-386-5},
 keywords = {software architecture},
 pages = {6071--6077},
 publisher = {IEEE},
 location = {Piscataway, NJ},
 title = {Toward adaptation and reuse of advanced robotic software},
 venue = {Shanghai, China},
 year = {2011}
}
\end{filecontents*}
\bibliography{database}

\begin{document}
\nocite{*}
\printbibliography{}

\end{document}

我需要的是格式为 2010 年 8 月 10 日至 12 日的活动日期。

答案1

尝试以下对日期内部的重新定义(请注意,您必须将其包装在 中\DefineBibliographyExtras{<doclang>})。这会更改日期的设置comp。因此,它不仅会改变您的eventdates。大多数日期comp默认为 ,但值得注意的例外是labeldate=yearurldate=short

\documentclass{article}
\usepackage[style=numeric,backend=biber]{biblatex}

\makeatletter
\DefineBibliographyExtras{english}{%
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldbibstring{#1}
      {\bibstring{\thefield{#1}}}
      {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}%
    \iffieldundef{#2}
      {}
      {\iffieldundef{#1}{}{\space}%
        \mkbibmonth{\thefield{#2}}%
        \iffieldundef{#3}{}{\space}}%
    \iffieldundef{#3}
      {}
      {\stripzeros{\thefield{#3}}}}%
%
\protected\gdef\lbx@us@mkdaterangetrunc@long#1#2{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[#2date]{%
         \datecircaprint
         \iffieldundef{#2season}
           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}}
           {\csuse{mkbibseasondate#1}{#2year}{#2season}}%
         \dateeraprint{#2}%
         \dateuncertainprint
         \iffieldundef{#2endyear}
           {}
           {\iffieldequalstr{#2endyear}{}
             {\mbox{\bibdaterangesep}}
             {\bibdaterangesep
              \enddatecircaprint
              \iffieldundef{#2season}
                {\iffieldsequal{#2year}{#2endyear}
                  {\iffieldsequal{#2month}{#2endmonth}
                    {\csuse{mkbibdate#1}{}{}{#2endday}}
                    {\csuse{mkbibdate#1}{}{#2endmonth}{#2endday}}}
                  {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}}
                {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
              \enddateuncertainprint
              \dateeraprint{#2}}}}}%
  \endgroup}%
}
\makeatother

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@inproceedings{Baker2011,
  author         = {Baker, Christopher R. and Dolan, John M. and Wang, Shige and Litkouhi, Bakhtiar B.},
  bookpagination = {page},
  booktitle      = {2011 IEEE Int. Conf. Robotics and Automation},
  doi            = {10.1109/ICRA.2011.5980355},
  eventdate      = {2011-05-09/2011-05-13},
  eventtitle     = {2011 IEEE International Conference on Robotics and Automation (ICRA 2011)},
  isbn           = {978-1-61284-386-5},
  keywords       = {software architecture},
  pages          = {6071--6077},
  publisher      = {IEEE},
  location       = {Piscataway, NJ},
  title          = {Toward adaptation and reuse of advanced robotic software},
  venue          = {Shanghai, China},
  year           = {2011},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

相关内容