使用“datetime”包,可以生成具有自定义日期格式的自定义日期,如下所示:
\usepackage{datetime}
\newdateformat{nwfmt}{\the\day, \THEDAY \monthday, \THEYEAR}
\newdate{mydate}{21}{12}{2020}
\begin{document}
\nwfmt
\mydate
\end{document}
但这并没有满足我的要求。我想要的是这样的格式:“2020 年 12 月 21 日,星期一”,即日期和月份的全名,且不包含大写字母。
答案1
可以很容易地将\DayName
from转换为小写,但必须明确定义(英语化scrdate
\monthname
沃纳的回答)。这是我能找到的最佳解决方案,用于完整的小写日期,如下所示:
\documentclass[border=2pt]{standalone}
\usepackage{datetime, scrdate}
\newdateformat{nwfmt}{\MakeLowercase{\DayName{\THEYEAR}{\THEMONTH}{\THEDAY}},
\THEDAY\ \monthname[\THEMONTH], \THEYEAR}
\makeatletter
\renewcommand{\monthname}[1][\month]{%
\@orgargctr=#1\relax
\ifcase\@orgargctr
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\or january%
\or february%
\or march%
\or april%
\or may%
\or june%
\or july%
\or august%
\or september%
\or october%
\or november%
\or december%
\else \PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\fi}
\makeatother
\newdate{mydate}{21}{12}{2020}
\begin{document}
\nwfmt\displaydate{mydate}
\end{document}