Latest news 2024-03-02: Ebook sale (3rd–9th March 2024): short story cybercrime fiction Unsocial Media free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99. For further details, see latest blog post.

datetime2 package FAQ

The time zone is incorrect 🔗

The datetime2 package obtains the date, time and time zone information in different ways, depending on the TeX engine:

XeLaTeX now provides \creationdate. The next version of datetime2 will add support for this. In the meantime, if you are using a new version of XeLaTeX, add the following line before you load datetime2:
\providecommand{\pdfcreationdate}{\creationdate}

If you’re not using XeLaTeX and the time zone is incorrect, then check the output of \pdfcreationdate or (if LuaLaTeX) \pdffeedback creationdate. If the time zone is incorrect in that output then the problem is that the TeX distribution that you are using is picking up a time zone that you weren’t expecting.

If TeX is installed on your local device, check your time settings. If TeX is installed on a remote server (for example, if you are using Overleaf) then it’s using the remote server’s time zone. If you are using latexmk (as with Overleaf), you can change the time zone environment variable, that is, the TZ variable used in POSIX systems. If you are not using latexmk then there are other ways of setting the TZ variable before you run a command. If you are not using a POSIX system then you will need to find out the appropriate equivalent setting or follow the XeLaTeX advice below.

If you are using XeLaTeX and can’t switch to a different engine, and you need the time zone, but you are unable to use texosquery either because the shell escape is completely disabled or your system doesn’t support Java applications then you will need to set up a build system that incorporates a way of saving the information that can be picked up by TeX. This depends on your operating system. (Note that changing the TZ environment variable doesn’t help in this case, as XeLaTeX doesn’t use that information.)

If you can use the texosquery application outside of TeX (that is, your system supports Java applications but TeX has the shell escape disabled) then you can use texosquery outside of TeX with the output saved to a temporary file and input the result. For example, run the following before running XeLaTeX:

texosquery -n > currentdate.tex
and include the following lines in your XeLaTeX document:
\usepackage{texosquery}
\TeXOSQueryFromFile{\pdfcreationdate}{currentdate}
This will define \pdfcreationdate regardless of whether or not you use datetime2 (but if you are using datetime2 make sure you set \pdfcreationdate before loading datetime2). Note that the texosquery application uses special markup in its output, so you can’t simply \input the file.

If you can’t use Java (for example, if you are using Overleaf) then you will need to find some other way of creating that temporary file. You can still use the above texosquery.sty code even if the file wasn’t created by the texosquery application, as long as the file contents has the correct format (which should match the format of \pdfcreationdate). I can’t help you with this. You will have to ask for help in a forum or other help channel applicable to your operating system.

2023-08-28 14:42:14


Permalink: https://www.dickimaw-books.com/faq.php?id=273
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=wrongtimezone

Category: datetime2 package
Topic: Unexpected Output