function getNbOfDaysInMonth($date) { $lang = JFactory::getLanguage(); // Get Nb of days in the month in Jalali/Persian calendar if ($lang->getTag() == 'fa-IR') { $date_to_persian = $date; $persian_month = date('m', strtotime($date_to_persian)); $persian_year = date('Y', strtotime($date_to_persian)); $leap_year = fa_IRDate::leap_persian($persian_year); if ($persian_month < 7) { $days = 31; } elseif ($persian_month == 12) { $days = $leap_year ? 30 : 29; } else { $days = 30; } } else { $days = date("t", strtotime($date)); } return $days; }
function getDays($d, $f) { $lang = JFactory::getLanguage(); $eventTimeZone = null; // Set Nb of days for the current month in Jalali/Persian calendar if ($lang->getTag() == 'fa-IR') { $date_to_persian = $d; $persian_month = date('m', strtotime($date_to_persian)); $persian_year = date('Y', strtotime($date_to_persian)); $leap_year = fa_IRDate::leap_persian($persian_year); if ($persian_month < 7) { $days = 31; } elseif ($persian_month == 12) { $days = $leap_year ? 30 : 29; } else { $days = 30; } } else { $days = date("t", strtotime($d)); } // Set Month and Year $ex_data = explode('-', $d); $month = $ex_data[1]; $year = $ex_data[0]; $jour = $ex_data[2]; $list = array(); // // Setting function of the visitor Time Zone // $today = time(); $config = JFactory::getConfig(); $joomla_offset = $config->get('offset'); $displayDatesTimezone = '0'; // Option not active $opt_TimeZone = isset($this->setTodayTimezone) ? $this->setTodayTimezone : ''; $gmt_today = gmdate('Y-m-d H:i:s', $today); $today_timestamp = strtotime($gmt_today); $GMT_timezone = 'Etc/UTC'; if ($opt_TimeZone == 'SITE') { // Joomla Server Time Zone $visitor_timezone = $joomla_offset; $offset = $this->get_timezone_offset($GMT_timezone, $visitor_timezone); $visitor_today = JHtml::date($today_timestamp + $offset, 'Y-m-d H:i:s', null); $UTCsite = $offset / 3600; if ($UTCsite > 0) { $UTCsite = '+' . $UTCsite; } if ($displayDatesTimezone == '1') { echo '<small>' . JHtml::date('now', 'Y-m-d H:i:s', true) . ' UTC' . $UTCsite . '</small><br />'; } } elseif ($opt_TimeZone == 'UTC') { // UTC Time Zone $offset = 0; $visitor_today = JHtml::date($today_timestamp + $offset, 'Y-m-d H:i:s', null); $UTC = $offset / 3600; if ($UTC > 0) { $UTC = '+' . $UTC; } if ($displayDatesTimezone == '1') { echo '<small>' . gmdate('Y-m-d H:i:s', $today) . ' UTC' . $UTC . '</small><br />'; } } else { $visitor_today = JHtml::date($today_timestamp, 'Y-m-d H:i:s', null); } $date_today = str_replace(' ', '-', $visitor_today); $date_today = str_replace(':', '-', $date_today); $ex_data = explode('-', $date_today); $v_month = $ex_data[1]; $v_year = $ex_data[0]; $v_day = $ex_data[2]; $v_hours = $ex_data[3]; $v_minutes = $ex_data[4]; for ($a = 1; $a <= $days; $a++) { $calday = $a; $this_date_a = $year . '-' . $month . '-' . $a; if ($a == $v_day && $month == $v_month && $year == $v_year) { $classDay = 'style_Today'; } else { $classDay = 'style_Day'; } $datejour = date('Y-m-d', strtotime($this_date_a)); $this_year_month = $year . '-' . $month . '-00'; $list_a_date = date('Y-m-d H:i', strtotime($this_date_a)); // Set Date in tooltip header $list[$calday]['dateTitle'] = $this->formatDate($datejour); // $list[$calday]['datecal'] = JHtml::date($this_date_a, 'j', null); // $list[$calday]['monthcal'] = JHtml::date($this_date_a, 'm', null); // $list[$calday]['yearcal'] = JHtml::date($this_date_a, 'Y', null); $list[$calday]['date'] = date('Y-m-d H:i', strtotime($this_date_a)); // $list[$calday]['dateFormat'] = strftime($f, strtotime($this_date_a)); $list[$calday]['week'] = date('N', strtotime($this_date_a)); $list[$calday]['day'] = '<div class="' . $classDay . '">' . $a . '</div>'; // Set cal_date $list[$calday]['this_day'] = date('Y-m-d', strtotime($this_date_a)); // Added in 2.1.2 (change in NAME_day.php) $list[$calday]['ifToday'] = $classDay; $list[$calday]['Days'] = $a; // Set event array $list[$calday]['events'] = array(); } return $list; }