| 1 |
% This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04 |
| 2 |
% Example 46 Parsing Dates and Times and Reformatting |
| 3 |
% Label: "ex:parsetemporalreformat" |
| 4 |
% arara: pdflatex |
| 5 |
% arara: pdfcrop |
| 6 |
\documentclass[12pt]{article} |
| 7 |
\pagestyle{empty} |
| 8 |
% This will not only require datetime2.sty to be installed |
| 9 |
% but also datetime2-english should be installed |
| 10 |
\usepackage[en-GB]{datetime2} |
| 11 |
\usepackage{datatool-base} |
| 12 |
\begin{document} |
| 13 |
\DTLsetup{datetime={parse={auto-reformat}}} |
| 14 |
|
| 15 |
\DTLparse\result{2025-01-09} |
| 16 |
String value: \result. |
| 17 |
Data type: \DTLdatumtype{\result}. |
| 18 |
Value: \DTLdatumvalue{\result}. |
| 19 |
|
| 20 |
\DTLparse\result{2025-01-09T14:42:01} |
| 21 |
String value: \result. |
| 22 |
Data type: \DTLdatumtype{\result}. |
| 23 |
Value: \DTLdatumvalue{\result}. |
| 24 |
|
| 25 |
\DTLparse\result{2025-01-09T15:42:01+01:00} |
| 26 |
String value: \result. |
| 27 |
Data type: \DTLdatumtype{\result}. |
| 28 |
Value: \DTLdatumvalue{\result}. |
| 29 |
|
| 30 |
\DTLparse\result{14:42:01} |
| 31 |
String value: \result. |
| 32 |
Data type: \DTLdatumtype{\result}. |
| 33 |
Value: \DTLdatumvalue{\result}. |
| 34 |
\end{document} |