2

I want to be able to define a variable of an arbitrary date and print it in different languages. And since polyglossia automatically formats the \today date, I am sure this can be achieved with it.

I checked

which both use either datetime2 (which supersedes datetime) or isodate packages. I am not keen to load these packages - particularly since datetime2 interferes with polyglossia and downloads a sub-package for every language used.

True, I can manually change the \day, \month and \year variables so for example

\day=5
\month=2
\year=2017
\today

redefines \today and prints yesterday's date. But in this way, the real today's date is lost.

So, Is there a way to define an arbitrary date with polyglossia for localisation formatting and what would be the correct syntax for this variable?

1

You can set the registers in a group.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}

\setmainfont{EB Garamond}
\setmainlanguage{french}
\setotherlanguage{russian}

\newcommand{\printdate}[3]{% {<year>}{<month>}{<day>}
  \begingroup
  \year=#1\relax
  \month=#2\relax
  \day=#3\relax
  \today
  \endgroup
}

\begin{document}

Aujourd'hui: \today

Il y a quelque temps: \printdate{1969}{7}{11}

Aujourd'hui: \today

\begin{otherlanguage*}{russian}
Cегодня: \today

некоторое время назад: \printdate{1969}{7}{11}

Cегодня: \today
\end{otherlanguage*}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.