You are here

function _birthdays_show_date_2 in Birthdays 5

Same name and namespace in other branches
  1. 6 birthdays.module \_birthdays_show_date_2()

Format date, optionally hide year

1 call to _birthdays_show_date_2()
_birthdays_show_date in ./birthdays.module
Format date array

File

./birthdays.module, line 1472
The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an e-mail on their birthday automatically, and the administrator can receive daily reminders of…

Code

function _birthdays_show_date_2($day, $month, $year, $account, $type = 'small') {
  $output = '';

  // Determine format type
  switch ($type) {
    case 'medium':
      $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
      break;
    case 'small':
    default:
      $format = variable_get('date_format_short', 'm/d/Y - H:i');
  }

  // remove time from (- H:i)

  //$format = substr($format, 0, -6);

  // If admin or user decide to hide the age&year: hide year
  if ($year && (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_YES || variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER && $account->birthdays_user_hide_year == BIRTHDAYS_HIDE_YEAR_USER_YES)) {
    $year = NULL;
  }

  // Replacement array (can't use date() because of 1970 limitations in e.g. Windows PHP4)
  $replace = array(
    'd' => sprintf('%02d', $day),
    'D' => NULL,
    'j' => $day,
    'm' => sprintf('%02d', $month),
    'M' => map_month($month),
    'Y' => $year,
    'H:i' => NULL,
    'G:i' => NULL,
    'g:ia' => NULL,
    'F' => t(gmdate('F', mktime(0, 0, 0, $month, 15, 2000))),
  );

  // Translate string to correct format
  $output .= strtr($format, $replace);
  $output = trim($output, '/ ,.:-');
  return $output;
}