% This is an example document accompanying "LaTeX for Administrative Work" % See www.dickimaw-books.com/latex/admin/ for the book details, % including licence. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{mycustomdate}[2014/03/19 1.0 My custom date format] \RequirePackage{etoolbox}% \RequirePackage{pgfkeys,pgfcalendar} % Define an ordinal command: \newcommand*{\ord}[1]{% \number#1% \ifcase#1\or st\or nd\or rd\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or th\or st\or nd\or rd\or th\or th\or th\or th\or th\or th\or th\or st\fi } % Define registers needed by \printdate: \newcount\julianday \newcount\dayofweek % Define generic date format: \newcommand*{\datefmt}[4][]{% \ifstrempty{#1} {}% day of week missing {% \pgfcalendarweekdayname{#1}\space }% \ord{#4}~\pgfcalendarmonthname{#3} \number#2% } % Define command to convert ISO date to a form that can be used by \datefmt: \newcommand*{\printdate}[1]{% \pgfcalendardatetojulian{#1}{\julianday}% \pgfcalendarjuliantodate{\julianday}{\thisyear}{\thismonth}{\thisday}% \pgfcalendarjuliantoweekday{\julianday}{\dayofweek}% % Now display the date: \datefmt[\dayofweek]{\thisyear}{\thismonth}{\thisday}% } % Redefine \today to use the same format: \renewcommand*{\today}{% \pgfcalendardatetojulian{\year-\month-\day}{\julianday}% \pgfcalendarjuliantoweekday{\julianday}{\dayofweek}% \datefmt[\dayofweek]{\year}{\month}{\day}% } % Check if babel is used with the british option: \AtBeginDocument{% \ifdef{\datebritish}% check if \datebritish exists {% it does exist, so redefine it \renewcommand*{\datebritish}{% \renewcommand*{\today}{% \pgfcalendardatetojulian{\year-\month-\day}{\julianday}% \pgfcalendarjuliantoweekday{\julianday}{\dayofweek}% \datefmt[\dayofweek]{\year}{\month}{\day}% }% }% \datebritish }% {}% doesn't exist, do nothing } \endinput