summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/datetime2/samples/datetime2-sample-styles.tex
blob: 28d042f72970af116c485a9737848d7433b5b598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% This file is public domain.
% This document additionally requires the datetime2-english module
% to be installed.

% arara: pdflatex
\documentclass[english]{report}

\usepackage{datetime2}

%\DTMsetup{showseconds=false,datesep=/,timesep=.}

\newcommand{\testdate}[1]{%
  \DTMsetstyle{#1}\section{Style `#1'}\par
  \begin{tabular}{ll}
  Now: & \DTMnow.\\
  Positive Time Zone: & \DTMuse{mydate+}\\
  Negative Time Zone: & \DTMuse{mydate-}\\
  Zero Time Zone: & \DTMuse{mydate0}
  \end{tabular}\par
  \typeout{Date-Time (#1): \DTMnow.}%
}

\newcommand{\testtime}[1]{%
  \DTMsettimestyle{#1}%
  \section{#1}\par
  \begin{tabular}{ll}
  Now: & \DTMcurrenttime.\\
  0 milliseconds: & \DTMusetime{mydate+}.\\
  45 milliseconds: & \DTMusetime{mydate2}.\\
  Noon: & \DTMusetime{noon}.\\
  Midnight (0hrs): & \DTMusetime{midnight1}.\\
  Midnight (24hrs): & \DTMusetime{midnight2}.\\
  Morning: & \DTMusetime{8am}.\\
  Evening: & \DTMusetime{8pm}.\\
  Post-Midday: & \DTMusetime{1203}.\\
  Post-Midnight (24hr): & \DTMusetime{2401}.\\
  Post-Midnight (0hr): & \DTMusetime{0001}.
  \end{tabular}\par
  \typeout{Time (#1): \DTMcurrenttime.
   \DTMusetime{mydate}.
   \DTMusetime{mydate2}.
   \DTMusetime{noon}.
   \DTMusetime{midnight1}.
   \DTMusetime{midnight2}.
   \DTMusetime{8am}.
   \DTMusetime{8pm}.
   \DTMusetime{1203}.
   \DTMusetime{2401}.
   \DTMusetime{0001}.
  }%
}

\begin{document}
\chapter{Date-Time Styles}
\DTMsavetimestamp{mydate+}{2015-04-01T08:05:00+01:00}
\DTMsavetimestamp{mydate-}{2015-04-01T08:05:00-01:00}
\DTMsavetimestamp{mydate0}{2015-04-01T08:05:00+00:00}

\testdate{default}

\testdate{iso}

\testdate{pdf}

\testdate{ddmmyyyy}

\testdate{dmyyyy}

\testdate{dmyy}

\testdate{mmddyyyy}

\testdate{mdyyyy}

\testdate{mdyy}

\testdate{yyyymd}

\chapter{Time Styles}

\DTMsavetimestamp{mydate2}{2015-04-01T08:13:45+01:00}
\DTMsavetime{noon}{12:00:00}
\DTMsavetime{midnight1}{00:00:00}
\DTMsavetime{midnight2}{24:00:00}
\DTMsavetime{8am}{08:00:00}
\DTMsavetime{8pm}{20:00:00}
\DTMsavetime{1203}{12:03:00}
\DTMsavetime{2401}{24:01:00}
\DTMsavetime{0001}{00:01:00}

\testtime{hmmss}

\testtime{englishampm}

\renewcommand*{\DTMenglishampmfmt}[1]{\protect\textsc{#1}}

\bigskip

(Redefining \verb|\DTMenglishampmfmt| for following test.)
\testtime{englishampm}

\end{document}