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