Example #1
0
 /**
  * Formats a date, using an alternative format if the given date is the same
  * day as today.
  *
  * \param $format_if_today
  *   A format specifier in strftime() syntax, used if the date is today.
  * \param $format_if_not_today
  *   A format specifier in strftime() syntax, used if the date is not today.
  * \param $date
  *   A date-like object (optional).
  *
  * \return
  *   A formatted date representation.
  *
  * \see AnewtDateTime::format
  * \see AnewtDateTime::format_if_current_year
  */
 static function format_if_today($format_if_today, $format_if_not_today, $date)
 {
     if (is_null($date)) {
         return null;
     }
     assert('$date instanceof AnewtDateTimeAtom;');
     assert('is_string($format_if_today)');
     assert('is_string($format_if_not_today)');
     if (AnewtDateTime::is_today($date)) {
         return strftime($format_if_today, $date->timestamp());
     } else {
         return strftime($format_if_not_today, $date->timestamp());
     }
 }