Пример #1
0
 /**
  * Gets the date as a formatted string in a local calendar.
  *
  * @param   string   $format     The date format specification string (see {@link PHP_MANUAL#date})
  * @param   boolean  $local      True to return the date string in the local time zone, false to return it in GMT.
  * @param   boolean  $translate  True to translate localised strings
  *
  * @return  string   The date string in the specified format format.
  *
  * @since   11.1
  */
 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])j/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])z/', "\\1" . self::DAY_YEAR, $format);
     $format = preg_replace('/(^|[^\\\\])M/', "\\1" . self::MONTH_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])F/', "\\1" . self::MONTH_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])n/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])t/', "\\1" . self::MONTH_LENGTH, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])a/', "\\1" . self::AM_LOWER, $format);
     $format = preg_replace('/(^|[^\\\\])A/', "\\1" . self::AM_UPPER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     $jd = gregoriantojd($this->month, $this->day, $this->year);
     $lunarDate = self::jdtolunar($jd);
     $m = $lunarDate['mon'];
     $d = $lunarDate['day'];
     $y = $lunarDate['year'];
     // Manually modify the strings in the formated time.
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $d, $return);
     }
     if (strpos($return, self::DAY_NUMBER2) !== false) {
         $return = str_replace(self::DAY_NUMBER2, sprintf("%02d", $d), $return);
     }
     if (strpos($return, self::DAY_YEAR) !== false) {
         $return = str_replace(self::DAY_YEAR, $jd - self::lunartojd(1, 1, $y) + 1, $return);
     }
     if (strpos($return, self::MONTH_ABBR) !== false) {
         $return = str_replace(self::MONTH_ABBR, $this->monthToString($m, true), $return);
     }
     if (strpos($return, self::MONTH_NAME) !== false) {
         $return = str_replace(self::MONTH_NAME, $this->monthToString($m), $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $m, $return);
     }
     if (strpos($return, self::MONTH_NUMBER2) !== false) {
         $return = str_replace(self::MONTH_NUMBER2, sprintf("%02d", $m), $return);
     }
     if (strpos($return, self::MONTH_LENGTH) !== false) {
         $return = str_replace(self::MONTH_LENGTH, $m == 12 && self::leap_lunar($y) ? 30 : $m % 2 ? 30 : 29, $return);
     }
     if (strpos($return, self::YEAR_ABBR) !== false) {
         $return = str_replace(self::YEAR_ABBR, sprintf("%02d", $y % 100), $return);
     }
     if (strpos($return, self::YEAR_NAME) !== false) {
         $return = str_replace(self::YEAR_NAME, $y, $return);
     }
     if (strpos($return, self::AM_LOWER) !== false) {
         $return = str_replace(self::AM_LOWER, $this->format('a', $local) == 'pm' ? JText::_('PM_SHORT') : JText::_('AM_SHORT'), $return);
     }
     if (strpos($return, self::AM_UPPER) !== false) {
         $return = str_replace(self::AM_UPPER, $this->format('a', $local) == 'pm' ? JText::_('PM') : JText::_('AM'), $return);
     }
     return $return;
 }
Пример #2
0
 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])j/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])z/', "\\1" . self::DAY_YEAR, $format);
     $format = preg_replace('/(^|[^\\\\])M/', "\\1" . self::MONTH_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])F/', "\\1" . self::MONTH_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])n/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])t/', "\\1" . self::MONTH_LENGTH, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])a/', "\\1" . self::AM_LOWER, $format);
     $format = preg_replace('/(^|[^\\\\])A/', "\\1" . self::AM_UPPER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     $jd = gregoriantojd($this->month, $this->day, $this->year);
     $jalaliDate = self::jd_to_persian($jd);
     $m = $jalaliDate['mon'];
     $d = $jalaliDate['day'];
     $y = $jalaliDate['year'];
     // Manually modify the strings in the formated time.
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $d, $return);
     }
     if (strpos($return, self::DAY_NUMBER2) !== false) {
         $return = str_replace(self::DAY_NUMBER2, sprintf("%02d", $d), $return);
     }
     if (strpos($return, self::DAY_YEAR) !== false) {
         $return = str_replace(self::DAY_YEAR, $jd - self::persian_to_jd(1, 1, $y) + 1, $return);
     }
     if (strpos($return, self::MONTH_ABBR) !== false) {
         $return = str_replace(self::MONTH_ABBR, self::$month_names[$m - 1], $return);
     }
     if (strpos($return, self::MONTH_NAME) !== false) {
         $return = str_replace(self::MONTH_NAME, self::$month_names[$m - 1], $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $m, $return);
     }
     if (strpos($return, self::MONTH_NUMBER2) !== false) {
         $return = str_replace(self::MONTH_NUMBER2, sprintf("%02d", $m), $return);
     }
     if (strpos($return, self::MONTH_LENGTH) !== false) {
         $return = str_replace(self::MONTH_LENGTH, $m < 7 ? 31 : $m < 12 ? 30 : self::leap_persian($y) ? 30 : 29, $return);
     }
     if (strpos($return, self::YEAR_ABBR) !== false) {
         $return = str_replace(self::YEAR_ABBR, sprintf("%02d", $y % 100), $return);
     }
     if (strpos($return, self::YEAR_NAME) !== false) {
         $return = str_replace(self::YEAR_NAME, $y, $return);
     }
     if (strpos($return, self::AM_LOWER) !== false) {
         $return = str_replace(self::AM_LOWER, $this->format('a', $local) == 'pm' ? 'ب ظ' : 'ق ظ', $return);
     }
     if (strpos($return, self::AM_UPPER) !== false) {
         $return = str_replace(self::AM_UPPER, $this->format('a', $local) == 'pm' ? 'ب ظ' : 'ق ظ', $return);
     }
     return $return;
 }
Пример #3
0
<?php

/**
 * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component
 *
 * @package     jbzoo
 * @version     2.x Pro
 * @author      JBZoo App http://jbzoo.com
 * @copyright   Copyright (C) JBZoo.com,  All rights reserved.
 * @license     http://jbzoo.com/license-pro.php JBZoo Licence
 * @coder       Alexander Oganov <*****@*****.**>
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$date = new JDate($order->created);
echo $date->calendar($params->get('format', 'D, d M Y H:i'), false, true);
Пример #4
0
 /**
  * Gets the date as a formatted string.
  *
  * @param	string	The date format specification string (see {@link PHP_MANUAL#date})
  * @param	boolean	True to return the date string in the local time zone, false to return it in GMT.
  * @return	string	The date string in the french republican calendar (see @link{http://en.wikipedia.org/wiki/French_Republican_Calendar}).
  * @since	1.6
  */
 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])H/', "\\1" . self::HOUR_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])i/', "\\1" . self::MINUTE_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])s/', "\\1" . self::SECOND_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])S/', "\\1" . self::ORDINAL_NUMBER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     // convNumber : true = thai number , false = arabic number
     $convNumber = false;
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $this->numToString($this->day, $convNumber), $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $this->numToString($this->month, $convNumber), $return);
     }
     if (strpos($return, self::YEAR_NUMBER) !== false) {
         $return = str_replace(self::YEAR_NUMBER, $this->yearToString($this->year, $convNumber), $return);
     }
     if (strpos($return, self::YEAR_NUMBER2) !== false) {
         $return = str_replace(self::YEAR_NUMBER2, JString::substr($this->yearToString($this->year, $convNumber), -2), $return);
     }
     if (strpos($return, self::HOUR_NUMBER) !== false) {
         $return = str_replace(self::HOUR_NUMBER, $this->numToString($this->hour, $convNumber), $return);
     }
     if (strpos($return, self::MINUTE_NUMBER) !== false) {
         $return = str_replace(self::MINUTE_NUMBER, $this->numToString($this->minute, $convNumber), $return);
     }
     if (strpos($return, self::SECOND_NUMBER) !== false) {
         $return = str_replace(self::SECOND_NUMBER, $this->numToString($this->second, $convNumber), $return);
     }
     if (strpos($return, self::ORDINAL_NUMBER) !== false) {
         $return = str_replace(self::ORDINAL_NUMBER, $this->numToString($this->ordinal, $convNumber), $return);
     }
     return $return;
 }
Пример #5
0
require_once dirname(__FILE__) . '/helper.php';
$params->id = $module->id;
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
$items = $params->get('items');
foreach ($items as $item) {
    switch ($item) {
        case 'analog':
            $analog_clock = ModDateTimeHelper::getAnalogClock($params);
            break;
        case 'digital':
            $digital_clock = ModDateTimeHelper::getDigitalClock($params);
            break;
        case 'day':
            $offset = $params->get('offset', 'UTC');
            $today = new JDate('now', $offset);
            $day_name = $today->calendar('l', true);
            break;
        case 'timezone':
            $timezone = ModDateTimeHelper::getTimeZoneText($params);
            break;
        case 'gregorian':
            $gregorian_date = ModDateTimeHelper::getGregorianDate($params);
            break;
        case 'solar':
            $solar_date = ModDateTimeHelper::getSolarDate($params);
            break;
        case 'lunar':
            $lunar_date = ModDateTimeHelper::getLunarDate($params);
            break;
    }
}