The public sources for my resume. These sources are auto compiled and published upon changes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.1 KiB

  1. \newcounter{datetoday}
  2. \newcounter{diffyears}
  3. \newcounter{diffmonths}
  4. \newcounter{diffdays}
  5. % Function curtesy of Martin Scharrer
  6. % http://tex.stackexchange.com/questions/14518/difference-between-two-dates
  7. \newcommand{\difftoday}[3]{%
  8. \setmydatenumber{datetoday}{\the\year}{\the\month}{\the\day}%
  9. \setmydatenumber{diffdays}{#1}{#2}{#3}%
  10. \addtocounter{diffdays}{-\thedatetoday}%
  11. \ifnum\value{diffdays}>0
  12. \def\diffbefore{in }%
  13. \def\diffafter{}%
  14. \else
  15. \def\diffbefore{}%
  16. \def\diffafter{}%
  17. \setcounter{diffdays}{-\value{diffdays}}%
  18. \fi
  19. \setcounter{diffyears}{\value{diffdays}/365}%
  20. \setcounter{diffdays}{\value{diffdays}-365*\value{diffyears}}%
  21. \setcounter{diffmonths}{\value{diffdays}/30}%
  22. \setcounter{diffdays}{\value{diffdays}-30*\value{diffmonths}}%
  23. %
  24. \diffbefore
  25. \ifnum\value{diffyears}=0
  26. \else
  27. \ifnum\value{diffyears}>1
  28. \thediffyears\space years\ignorespacesafterend
  29. \else
  30. \thediffyears\space year\ignorespacesafterend
  31. \fi
  32. \fi
  33. \ifnum\value{diffmonths}=0
  34. \else
  35. \ifnum\value{diffyears}>0
  36. ,
  37. \fi
  38. \ifnum\value{diffmonths}>1
  39. \thediffmonths\space months\ignorespacesafterend
  40. \else
  41. \thediffmonths\space month\ignorespacesafterend
  42. \fi
  43. \fi
  44. \diffafter
  45. }
  46. \newcommand{\diffdates}[6]{%
  47. \setmydatenumber{datetoday}{#4}{#5}{#6}%
  48. \setmydatenumber{diffdays}{#1}{#2}{#3}%
  49. \addtocounter{diffdays}{-\thedatetoday}%
  50. \ifnum\value{diffdays}>0
  51. \def\diffbefore{in }%
  52. \def\diffafter{}%
  53. \else
  54. \def\diffbefore{}%
  55. \def\diffafter{}%
  56. \setcounter{diffdays}{-\value{diffdays}}%
  57. \fi
  58. \setcounter{diffyears}{\value{diffdays}/365}%
  59. \setcounter{diffdays}{\value{diffdays}-365*\value{diffyears}}%
  60. \setcounter{diffmonths}{\value{diffdays}/30}%
  61. \setcounter{diffdays}{\value{diffdays}-30*\value{diffmonths}}%
  62. %
  63. \diffbefore
  64. \ifnum\value{diffyears}=0
  65. \else
  66. \ifnum\value{diffyears}>1
  67. \thediffyears\space years\ignorespacesafterend
  68. \else
  69. \thediffyears\space year\ignorespacesafterend
  70. \fi
  71. \fi
  72. \ifnum\value{diffmonths}=0
  73. \else
  74. \ifnum\value{diffyears}>0
  75. ,
  76. \fi
  77. \ifnum\value{diffmonths}>1
  78. \thediffmonths\space months\ignorespacesafterend
  79. \else
  80. \thediffmonths\space month\ignorespacesafterend
  81. \fi
  82. \fi
  83. \diffafter
  84. }