Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Compile and read me!
- \documentclass[a4paper,12pt]{article}
- \usepackage{fmtcount,etoolbox}\def\x{\the\numexpr}\def\n[#1]{\numberstringnum{#1}}\def\h[#1]{\ifnumequal{#1}{0}{twelve night}{\ifnumequal{#1}{12}{twelve noon}{\ifnumless{#1}{13}{\n[#1] o'clock AM}{\n[\x#1-12\relax] o'clock PM}}}}\def\m[#1]{\ifnumequal{#1}{15}{quarter}{\ifnumequal{#1}{30}{half}{\n[#1] minutes}}}\newcounter{c}\def\f[#1]#2{\ifnumequal{#2}{0}{\h[#1]}{\ifnumless{#2}{31}{\m[#2] past \h[#1]}{\setcounter{c}{\x60-#2\relax}\m[\thec] to \h[\x#1+1\relax]}}}
- \begin{document}
- \noindent
- \textbf{Test cases:} \\ \\
- 00:00 = \f[00]{00} \\
- 12:00 = \f[12]{00} \\
- 06:00 = \f[6]{00} \\
- 18:00 = \f[18]{00} \\
- 06:15 = \f[6]{15} \\
- 18:45 = \f[18]{45} \\
- 11:30 = \f[11]{30} \\
- 13:22 = \f[13]{22} \\
- 17:43 = \f[17]{43} \\
- \noindent
- \textbf{More test cases:} \\ \\
- 00:13 = \f[00]{13} \\
- 12:12 = \f[12]{12} \\
- 12:15 = \f[12]{15} \\
- 11:45 = \f[11]{45} \\
- 11:41 = \f[11]{41} \\
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement