woo@ornl.gov (John W. Wooten) (06/08/91)
Found a way to keep resumes and other documents that include statements like in the past xx years, etc. Updated. (Thanks to dmjones@theory.lcs.mit.edu (David M. Jones) for getting me started on the solution. ) This \age{mm/dd/yy} gives # of years between today and mm/dd/yy. If dates before 1900 needed then comment out line with 1900 and use \age{mm/dd/yyyy}. ---- % \catcode`@=11 \newcount\@tempnuma \def\@null{null} \def\age#1{\@age#1\@null} \def\@age#1/#2/#3\@null{% \@tempnuma\year \advance\@tempnuma by -1900 % Comment this line out for dates of % the form 2/24/1967 - last 2 digits of yr. \advance\@tempnuma by -#3\relax % gives # of years %\number\@tempnuma \ifnum#1 > \month %anniv month is later in year \advance\@tempnuma by -1\relax \else \ifnum#1 = \month %anniv month is this month \ifnum#2 > \day %anniv day is later in month \advance\@tempnuma by -1\relax \fi\relax \fi\relax \fi\relax \number\@tempnuma} \catcode`@=12 % Test cases \age{5/6/84}, \age{5/7/84}, \age{5/8/84}, \age{6/6/84}, \age{6/7/84}, \age{6/8/84}, \age{7/6/84}, \age{7/7/84}, \age{7/8/84}. %
ejo@ims.alaska.edu (Eric Olson) (06/10/91)
In article <1991Jun7.194112.7886@cs.utk.edu> woo@ornl.gov (John W. Wooten) writes: >This \age{mm/dd/yy} gives # of years between today and mm/dd/yy. >If dates before 1900 needed then comment out line with 1900 and >use \age{mm/dd/yyyy}. It seems to me that it's much easier just to stick an extra if in, and if (yy/yyyy) is less than 100, treat it as an after 1900 date: I just like it better that way because I'm terrible at remembering what little tricks and fixes that macro there requires after a month or two. ---- % \catcode`@=11 \newcount\@tempnuma \def\@null{null} \def\age#1{\@age#1\@null} \def\@age#1/#2/#3\@null{% \@tempnuma\year \ifnum#1<100 \advance\@tempnuma by -1900 \fi \advance\@tempnuma by -#3\relax % gives # of years %\number\@tempnuma \ifnum#1 > \month %anniv month is later in year \advance\@tempnuma by -1\relax \else \ifnum#1 = \month %anniv month is this month \ifnum#2 > \day %anniv day is later in month \advance\@tempnuma by -1\relax \fi\relax \fi\relax \fi\relax \number\@tempnuma} \catcode`@=12 % Eric Olson <ejo@ims.alaska.edu>