Hi everybody,

I`m newbie to drupal,and I want to use drupal for our client in different nations and religion,and I want all times which they are shown in their site to show in their native calendar such as Gregorian , Jewish or solar calendar,

How can I set new calndar in the drupal ?

Where Can I use our available Gregorian calendars function for changing all time to other calendars in drupal ?

any information would be greatly appreciated.
Thanks in advance,

Comments

Wutimer’s picture

I used the Calendar module and made the following updates to the the theme template.php file:

First, I added a custom function that returned an array of Jewish date parts:


/**
 * Returns array of hebrew dat parts
 *
 * @param integer $year
 * @param integer $month
 * @param integer $day
 * @return array (year, month, day)
 */
function get_hebrew_date_parts ($year, $month, $day) {

    $jdDate = gregoriantojd($month,$day,$year);

    $hebrewMonthName = jdmonthname($jdDate,4);

    $hebrewDate = jdtojewish($jdDate);

    list($hebrewMonth, $hebrewDay, $hebrewYear) = split('/',$hebrewDate);

    return array('year' => $hebrewYear, 'month' => $hebrewMonth, 'day' => $hebrewDay, 'monthname' => $hebrewMonthName);
}

Next, you need to replace the theme_calendar_date_box() function as follows (my example uses garland):

/**
 * Format an date's day box in a calendar ADDING JEWISH DATE
 */
function garland_calendar_date_box($year, $month, $day, $view, $mini = FALSE, $selected = FALSE, $url, $append = '') {

  $hebdate = get_hebrew_date_parts($year, $month, $day);

  $url = $url ? $url .'/'. $year .'/'. $month .'/'. $day : 'calendar/'. $year .'/'. $month .'/'. $day;
  if ($mini) {
    if ($selected) {
      return '<div class="mini-day-on">'. l($day, $url, NULL, $append) .'</div>';
    }
    else {
      return '<div class="mini-day-off">'. l($day, $url, NULL, $append) .'</div>';
    }
  }
  switch ($view) {
    case 'table':
        $output = '<div class="day">';
        $output .= l(t('!month / !day', array('!month' => $month, '!day' => $day)), $url, NULL, $append);
        $output .= '<div class="hebrew">' . $hebdate['day'] . ' ' . $hebdate['monthname'] . '</div>';
        $output .= '</div>'."\n";
      break;
    case 'list':
        $output = '<div class="day">';
        $output .= $hebdate['day'] . ' ' . $hebdate['monthname'] . '<br/>';
        $output .= l(date_format_date('l, F j, Y', date_mktime(array('mon' => $month, 'mday' => $day, 'year' => $year))), $url, NULL, $append);
        $output .= '</div>'."\n";
      break;
    case 'day':
     break;
    default:
        $output = '<div class="day">';
        $output .= l($day, $url, NULL, $append);
        $output .= '<div class="hebrew">' . $hebdate['day'] . ' ' . $hebdate['monthname'] . '</div>';
        $output .= '</div>'."\n";
      break;
  }
  return $output;
}

The above solution simply adds the Jewish day/month to each calendar day on the month view; it also does the same for the table view and list view.

I did not update the year view; thinking having both the Gregorian and Jewish dates listed on the calendar would be too much.