Just a short addendum:

Since you know that you'll only be stripping off one of the
known weekday names, there's also a simpler solution:

  .\" ----------------------------------------------------------------
  .de DATE*SHORT
  \c
  .XX \\*[DATE*FULL]
  ..
  .de XX
  .ds BB \\$*
  .ds AA \\$1
  .shift
  .if '\\*(AA'Sunday,'    .ds BB \\$*
  .if '\\*(AA'Monday,'    .ds BB \\$*
  .if '\\*(AA'Tuesday,'   .ds BB \\$*
  .if '\\*(AA'Wednesday,' .ds BB \\$*
  .if '\\*(AA'Thursday,'  .ds BB \\$*
  .if '\\*(AA'Friday,'    .ds BB \\$*
  .if '\\*(AA'Saturday,'  .ds BB \\$*
  .BB
  ..
  .\" ----------------------------------------------------------------
  .ds DATE*FULL Friday, December 31, 2038
  .sp 3c
  Full date is: \*[DATE*FULL].
  .br
  Short date is: \*[DATE*SHORT].
  .\" ----------------------------------------------------------------

However, there is still a caveat with these solutions: although
\*[DATE*SHORT] may look like a (single-line) string expansion,
it is actually a (multi-line) macro call in disguise.  This
means that the following will not work:

  .ds LH Formatted on \*[DATE*SHORT]

(for example, to set the page header in some hypothetical
document).

Because the above is likely to lead to nasty surprises, I'd
prefer something with a slightly different application syntax:

  .\" ----------------------------------------------------------------
  .de SET_DATE
  .ds DATE*FULL \\$*
  .XX \\$*
  ..
  .de XX
  .ds DATE*SHORT \\$*
  .ds AA \\$1
  .shift
  .if '\\*(AA'Sunday,'    .ds DATE*SHORT \\$*
  .if '\\*(AA'Monday,'    .ds DATE*SHORT \\$*
  .if '\\*(AA'Tuesday,'   .ds DATE*SHORT \\$*
  .if '\\*(AA'Wednesday,' .ds DATE*SHORT \\$*
  .if '\\*(AA'Thursday,'  .ds DATE*SHORT \\$*
  .if '\\*(AA'Friday,'    .ds DATE*SHORT \\$*
  .if '\\*(AA'Saturday,'  .ds DATE*SHORT \\$*
  ..
  .\" ----------------------------------------------------------------
  .SET_DATE Friday, December 31, 2038
  .sp 3c
  Full date is: \*[DATE*FULL].
  .br
  Short date is: \*[DATE*SHORT].
  .\" ----------------------------------------------------------------

which uses DATE*SHORT as a "real" string instead of a macro.



Reply via email to