7. ⁎Dates and Times
There's a large list of packages related to dates and times on the calendar topic, timetable topic and date-time topic pages.
However, once you discount the plain TeX macros, the old LaTeX2.09 styles,
the packages that aren't included in TeX Live or MiKTeX, packages that don't
have English documentation and packages that don't have proper documentation
(just an example file or plain text file), then the list becomes much smaller
and can be divided into those that provide commands to: compute dates; display
calendars or timetables; display specific dates or times; or display the
current time or the current date in a particular format (by redefining
\today
). Some of the packages cover more than one of these categories.
The datetime package, which can be used to display formatted dates
and the current time, was described in Volume 1
and so is not covered here. Similarly the babel
package [7], which also redefines \today
, was
described in Volume 1. Since I started writing this book, I have
replaced datetime with datetime2, which uses some of
the code described in this chapter, so datetime2 is briefly
introduced in §7.1 The datetime2 Package.
\today
) indicate the time or date of the TeX run that
created the resulting PDF (or DVI) document. If you actually want
a real time clock in your document, you can use the
tdclock package [70]
however this will only work if your PDF viewer not only supports
JavaScript (such as Adobe Reader) but also has JavaScript
enabled.
Surprisingly none of the above CTAN date-related topics include the pgfcalendar package that comes with the pgf bundle [102]. This is a useful date utility package that can be used for computing dates by adding or subtracting days from a given date. It also has commands that display month and week day names, so it can be used for parsing and formatting dates. In addition, since the pgf package's main function is graphical, pgfcalendar can be used to display calendars.
This chapter is arranged as follows:
- §7.1 The datetime2 Package briefly introduces the datetime2
package.
- §7.2 The pgfcalendar Package Utility Commands describes the date utility
commands of the pgfcalendar package that can: parse a date, or
a date offset from another date, and convert it to a Julian day
number; convert a Julian day number into an ISO-date; determine the
week day from a Julian day number; test a date (for example, test if
the date is on a particular week day, or is earlier or later than
another date).
- §7.3 Displaying a Date describes how to display a date
using your own preferred format.
- §7.5 Displaying a Calendar describes how to use the
pgfcalendar package to display a calendar.
- §7.4 Parsing and Displaying Times describes how to parse and display times.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).