title: Formatting Date in Freemarker to say "Today", "Yesterday", etc
body: <p>Is there a way in freemarker to compare dates to test if the date is today or yesterday... or do I have to write code in Java to do these tests?</p>
  
  <p>I basically want to do this:</p>
  
  <pre><code>&lt;#------------------------------------------------------------------------------
   formatDate
  -------------------------------------------------------------------------------&gt;
  &lt;#macro formatDate date showTime=true&gt;
      &lt;#if date??&gt;
          &lt;span class="Date"&gt;
              &lt;#if date?is_today&gt;
                  Today
              &lt;#elseif date?is_yesterday&gt;
                  Yesterday
              &lt;#else&gt;
                  ${date?date}
              &lt;/#if&gt;
          &lt;/span&gt;
          &lt;#if showTime&gt;
              &lt;span class="Time"&gt;${date?time}&lt;/span&gt;
          &lt;/#if&gt;
      &lt;/#if&gt;
  &lt;/#macro&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong> My best guess to implement this is to pass "today" and "yesterday" into the model for the pages that use this function and then compare the date values against these 2 objects in the model. I am out of out of options, but I'd rather not have to do this for every page that uses this macro. Any other options that are nicer?</p>
  
  <pre><code>&lt;#if date??&gt;
      &lt;span class="Date"&gt;
          &lt;#if date?date?string.short == today?date?string.short&gt;
              Today
          &lt;#elseif date?date?string.short == yesterday?date?string.short&gt;
              Yesterday
          &lt;#else&gt;
              ${date?date}
          &lt;/#if&gt;
      &lt;/span&gt;
      &lt;#if showTime&gt;
          &lt;span class="Time"&gt;${date?time}&lt;/span&gt;
      &lt;/#if&gt;
  &lt;/#if&gt;
  </code></pre>