Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. %% Compile and read me!
  2. \documentclass[a4paper,12pt]{article}
  3.  
  4. \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]}}}
  5.  
  6. \begin{document}
  7.  
  8. \noindent
  9. \textbf{Test cases:} \\ \\
  10. 00:00 = \f[00]{00} \\
  11. 12:00 = \f[12]{00} \\
  12. 06:00 = \f[6]{00} \\
  13. 18:00 = \f[18]{00} \\
  14. 06:15 = \f[6]{15} \\
  15. 18:45 = \f[18]{45} \\
  16. 11:30 = \f[11]{30} \\
  17. 13:22 = \f[13]{22} \\
  18. 17:43 = \f[17]{43} \\
  19.  
  20. \noindent
  21. \textbf{More test cases:} \\ \\
  22. 00:13 = \f[00]{13} \\
  23. 12:12 = \f[12]{12} \\
  24. 12:15 = \f[12]{15} \\
  25. 11:45 = \f[11]{45} \\
  26. 11:41 = \f[11]{41} \\
  27.  
  28. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement