当前位置: 首页>>代码示例>>PHP>>正文


PHP jalali_to_gregorian函数代码示例

本文整理汇总了PHP中jalali_to_gregorian函数的典型用法代码示例。如果您正苦于以下问题:PHP jalali_to_gregorian函数的具体用法?PHP jalali_to_gregorian怎么用?PHP jalali_to_gregorian使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了jalali_to_gregorian函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mstart

/**
 * Find Day Begining Of Month
 * 
 * @deprecated since 5.0.0
 */
function mstart($month, $day, $year)
{
    list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
    list($year, $month, $day) = jalali_to_gregorian($jyear, $jmonth, "1");
    $timestamp = mktime(0, 0, 0, $month, $day, $year);
    return date("w", $timestamp);
}
开发者ID:vah7id,项目名称:wp-persian-openshift,代码行数:12,代码来源:deprecated_fns.php

示例2: _process

 function _process()
 {
     global $messageStack, $osC_Database, $osC_Language, $osC_Customer;
     $data = array();
     $j_to_g = array();
     if (ACCOUNT_GENDER == '1') {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error'));
         }
     } else {
         $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : '';
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']);
             // tabdil shamsi be miladi
             $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']);
         } else {
             $messageStack->add('account_edit', $osC_Language->get('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_exists_error'));
             }
         } else {
             $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_check_error'));
         }
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if ($messageStack->size('account_edit') === 0) {
         if (osC_Account::saveEntry($data)) {
             // reset the session variables
             if (ACCOUNT_GENDER > -1) {
                 $osC_Customer->setGender($data['gender']);
             }
             $osC_Customer->setFirstName(trim($data['firstname']));
             $osC_Customer->setLastName(trim($data['lastname']));
             $osC_Customer->setEmailAddress($data['email_address']);
             $messageStack->add_session('account', $osC_Language->get('success_account_updated'), 'success');
         }
         osc_redirect(osc_href_link(FILENAME_ACCOUNT, null, 'SSL'));
     }
 }
开发者ID:sajad1441,项目名称:TomatoShop-v1,代码行数:60,代码来源:edit.php

示例3: beforeSave

 /**
  * Formating date value before save
  *
  * Should set (bool, string) correct type for empty value from html form,
  * neccessary for farther proccess, else date string
  *
  * @param Varien_Object $object
  * @throws Mage_Eav_Exception
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime
  */
 public function beforeSave($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $_formated = $object->getData($attributeName . '_is_formated');
     if (!$_formated && $object->hasData($attributeName)) {
         try {
             if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
                 require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
                 if ($object->getData($attributeName) != NULL) {
                     list($j_y, $j_m, $j_d) = explode('/', $object->getData($attributeName));
                     $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
                     $date = implode('-', $gregorianlArray);
                     $object->setData($attributeName, $date);
                 }
             }
             $value = $this->formatDate($object->getData($attributeName));
         } catch (Exception $e) {
             throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid date'));
         }
         if (is_null($value)) {
             $value = $object->getData($attributeName);
         }
         //Mage::log( "$attributeName, $value ") ;
         $object->setData($attributeName, $value);
         $object->setData($attributeName . '_is_formated', true);
     }
     return $this;
 }
开发者ID:nitronaj,项目名称:magentofa,代码行数:38,代码来源:Datetime.php

示例4: makeFromJalali

 private function makeFromJalali($time)
 {
     if (preg_match("#(\\d{2,4})([-/])(\\d{1,2})\\2(\\d{1,2})( +(\\d{1,2}):(\\d{1,2})(:(\\d{1,2}))?)?#", $time, $a)) {
         if (strlen($a[1]) == 2) {
             $a[1] = "13{$a[1]}";
         }
         list($yy, $mm, $dd) = jalali_to_gregorian($a[1], $a[3], $a[4]);
         if (!isset($a[5])) {
             $a[5] = ' 00:00:00';
         }
         $date = "{$yy}-{$mm}-{$dd} {$a[5]}";
         return strtotime($date);
     }
     return 0;
 }
开发者ID:redknight,项目名称:frot,代码行数:15,代码来源:Date.php

示例5: _convertDate

 protected function _convertDate($date, $locale)
 {
     if ($this->getColumn()->getFilterTime()) {
         try {
             if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
                 require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
                 list($j_y, $j_m, $j_d) = explode('/', $date);
                 $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
                 $date = implode('/', $gregorianlArray);
             }
             $dateObj = $this->getLocale()->date(null, null, $locale, false);
             //set default timezone for store (admin)
             $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
             //set date with applying timezone of store
             $dateObj->set($date, $this->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), $locale);
             //convert store date to default date in UTC timezone without DST
             $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
             return $dateObj;
         } catch (Exception $e) {
             return null;
         }
     }
     return parent::_convertDate($date, $locale);
 }
开发者ID:nitronaj,项目名称:magentofa,代码行数:24,代码来源:Datetime.php

示例6: days_of_year

function days_of_year($jmonth, $jday, $jyear)
{
    $year = "";
    $month = "";
    $year = "";
    $result = "";
    if ($jmonth == "01") {
        return $jday;
    }
    for ($i = 1; $i < $jmonth || $i == 12; $i++) {
        list($year, $month, $day) = jalali_to_gregorian($jyear, $i, "1");
        $result += lastday($month, $day, $year);
    }
    return $result + $jday;
}
开发者ID:jemmy655,项目名称:nodcms,代码行数:15,代码来源:jdf_helper.php

示例7: formatted_jalali_to_georgian

function formatted_jalali_to_georgian($dt)
{
    list($d, $t) = explode(" ", $dt);
    list($y, $m, $d) = explode("/", $d);
    list($y, $m, $d) = jalali_to_gregorian($y, $m, $d);
    return sprintf("%04d/%02d/%02d", $y, $m, $d) . " " . $t;
}
开发者ID:NaszvadiG,项目名称:BurgeCMF,代码行数:7,代码来源:jdate_helper.php

示例8: _prepareCollection

 protected function _prepareCollection()
 {
     if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
         require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
         $from = $this->getFilterData()->getData('from');
         list($j_y, $j_m, $j_d) = explode('-', $from);
         $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
         $gFrom = implode('/', $gregorianlArray);
         $this->getFilterData()->setFrom($gFrom);
         $to = $this->getFilterData()->getData('to');
         list($j_y, $j_m, $j_d) = explode('-', $to);
         $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
         $gTo = implode('/', $gregorianlArray);
         $this->getFilterData()->setTo($gTo);
     }
     $filterData = $this->getFilterData();
     if ($filterData->getData('from') == null || $filterData->getData('to') == null) {
         $this->setCountTotals(false);
         $this->setCountSubTotals(false);
         return parent::_prepareCollection();
     }
     $storeIds = $this->_getStoreIds();
     $orderStatuses = $filterData->getData('order_statuses');
     if (is_array($orderStatuses)) {
         if (count($orderStatuses) == 1 && strpos($orderStatuses[0], ',') !== false) {
             $filterData->setData('order_statuses', explode(',', $orderStatuses[0]));
         }
     }
     $resourceCollection = Mage::getResourceModel($this->getResourceCollectionName())->setPeriod($filterData->getData('period_type'))->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))->addStoreFilter($storeIds)->addOrderStatusFilter($filterData->getData('order_statuses'))->setAggregatedColumns($this->_getAggregatedColumns());
     if ($this->_isExport) {
         $this->setCollection($resourceCollection);
         return $this;
     }
     if ($filterData->getData('show_empty_rows', false)) {
         Mage::helper('reports')->prepareIntervalsCollection($this->getCollection(), $filterData->getData('from', null), $filterData->getData('to', null), $filterData->getData('period_type'));
     }
     if ($this->getCountSubTotals()) {
         $this->getSubTotals();
     }
     if ($this->getCountTotals()) {
         $totalsCollection = Mage::getResourceModel($this->getResourceCollectionName())->setPeriod($filterData->getData('period_type'))->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))->addStoreFilter($storeIds)->addOrderStatusFilter($filterData->getData('order_statuses'))->setAggregatedColumns($this->_getAggregatedColumns())->isTotals(true);
         foreach ($totalsCollection as $item) {
             $this->setTotals($item);
             break;
         }
     }
     $this->getCollection()->setColumnGroupBy($this->_columnGroupBy);
     $this->getCollection()->setResourceCollection($resourceCollection);
     return parent::_prepareCollection();
 }
开发者ID:nitronaj,项目名称:magentofa,代码行数:50,代码来源:Abstract.php

示例9: _prepareCollection

 protected function _prepareCollection()
 {
     $filter = $this->getParam($this->getVarNameFilter(), null);
     if (is_null($filter)) {
         $filter = $this->_defaultFilter;
     }
     if (is_string($filter)) {
         $data = array();
         $filter = base64_decode($filter);
         parse_str(urldecode($filter), $data);
         if (!isset($data['report_from'])) {
             // getting all reports from 2001 year
             $date = new Zend_Date(mktime(0, 0, 0, 1, 1, 2001));
             $data['report_from'] = $date->toString($this->getLocale()->getDateFormat('short'));
         }
         if (!isset($data['report_to'])) {
             // getting all reports from 2001 year
             $date = new Zend_Date();
             $data['report_to'] = $date->toString($this->getLocale()->getDateFormat('short'));
         }
         $this->_setFilterValues($data);
     } else {
         if ($filter && is_array($filter)) {
             $this->_setFilterValues($filter);
         } else {
             if (0 !== sizeof($this->_defaultFilter)) {
                 $this->_setFilterValues($this->_defaultFilter);
             }
         }
     }
     /** @var $collection Mage_Reports_Model_Resource_Report_Collection */
     $collection = Mage::getResourceModel('reports/report_collection');
     $collection->setPeriod($this->getFilter('report_period'));
     if ($this->getFilter('report_from') && $this->getFilter('report_to')) {
         /**
          * Validate from and to date
          */
         try {
             if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
                 require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
                 $from = $this->getFilter('report_from');
                 list($j_y, $j_m, $j_d) = explode('/', $from);
                 $From = jalali_to_gregorian($j_y, $j_m, $j_d);
                 $report_from = implode('/', $From);
                 $to = $this->getFilter('report_to');
                 list($j_y, $j_m, $j_d) = explode('/', $to);
                 $gTo = jalali_to_gregorian($j_y, $j_m, $j_d);
                 $report_to = implode('/', $gTo);
                 $part = Zend_Date::DATE_MEDIUM;
             } else {
                 $report_from = $this->getFilter('report_from');
                 $report_to = $this->getFilter('report_to');
                 $part = Zend_Date::DATE_SHORT;
             }
             $from = $this->getLocale()->date($report_from, $part, null, false);
             $to = $this->getLocale()->date($report_to, $part, null, false);
             $collection->setInterval($from, $to);
         } catch (Exception $e) {
             $this->_errors[] = Mage::helper('reports')->__('Invalid date specified.');
         }
     }
     /**
      * Getting and saving store ids for website & group
      */
     $storeIds = array();
     if ($this->getRequest()->getParam('store')) {
         $storeIds = array($this->getParam('store'));
     } elseif ($this->getRequest()->getParam('website')) {
         $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
     } elseif ($this->getRequest()->getParam('group')) {
         $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
     }
     // By default storeIds array contains only allowed stores
     $allowedStoreIds = array_keys(Mage::app()->getStores());
     // And then array_intersect with post data for prevent unauthorized stores reports
     $storeIds = array_intersect($allowedStoreIds, $storeIds);
     // If selected all websites or unauthorized stores use only allowed
     if (empty($storeIds)) {
         $storeIds = $allowedStoreIds;
     }
     // reset array keys
     $storeIds = array_values($storeIds);
     $collection->setStoreIds($storeIds);
     if ($this->getSubReportSize() !== null) {
         $collection->setPageSize($this->getSubReportSize());
     }
     $this->setCollection($collection);
     Mage::dispatchEvent('adminhtml_widget_grid_filter_collection', array('collection' => $this->getCollection(), 'filter_values' => $this->_filterValues));
 }
开发者ID:nitronaj,项目名称:magentofa,代码行数:89,代码来源:Grid.php

示例10: array

     $adult = array();
     $roomscount = $_POST['room-num'];
     for ($k = 1; $k <= $roomscount; $k++) {
         $adult[$k] = $_POST['room-' . $k . '-ad-num'];
     }
     foreach ($_POST as $key => $value) {
         $_SESSION[$key] = $_POST[$key];
     }
     $arr = split('_', $_SESSION['city_id']);
     $country = $arr[0];
     $city = $arr[1];
     $_SESSION['city'] = $city;
     $arr_in = split('/', $_SESSION['date-in']);
     $_SESSION['check-in'] = jalali_to_gregorian($arr_in[0], $arr_in[1], $arr_in[2], '/');
     $arr_in = split('/', $_SESSION['date-out']);
     $_SESSION['check-out'] = jalali_to_gregorian($arr_in[0], $arr_in[1], $arr_in[2], '/');
     $arr = explode('_', $_POST['city_id']);
     $r = new Request();
     $ctrl = new HotelController();
     $ctrl->safar_Aviable();
     break;
 case 'gallery':
     $ctrl = new HotelController();
     $ctrl->Gallery($hid);
     break;
 case 'reserve':
     foreach ($_POST as $key => $item) {
         $_SESSION['Reserve'][$key] = $item;
     }
     //print_r($_SESSION['Reserve']);exit;
     $ctrl = new HotelController();
开发者ID:jnaroogheh,项目名称:darvishi,代码行数:31,代码来源:index.php

示例11: print_annual_balance_breakdown_detail

function print_annual_balance_breakdown_detail()
{
    global $path_to_root, $date_system;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    if ($dim == 2) {
        $date = $_POST['PARAM_0'];
        $dimension = $_POST['PARAM_1'];
        $dimension2 = $_POST['PARAM_2'];
        $comments = $_POST['PARAM_3'];
        $destination = $_POST['PARAM_4'];
    } else {
        if ($dim == 1) {
            $date = $_POST['PARAM_0'];
            $dimension = $_POST['PARAM_1'];
            $comments = $_POST['PARAM_3'];
            $destination = $_POST['PARAM_4'];
        } else {
            $date = $_POST['PARAM_0'];
            $comments = $_POST['PARAM_3'];
            $destination = $_POST['PARAM_4'];
        }
    }
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $title = _("Annual Balance Breakdown - Detailed");
    $output_filename = "AnnualBalanceBreakDownDetail";
    $fontsize = 7;
    $page_size = user_pagesize();
    $page_orientation = 'L';
    $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10);
    $excelColWidthFactor = 5;
    $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor);
    $enddate = end_month($date);
    $dec = user_price_dec();
    // Lay out the columns for this report
    //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760);
    //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15-
    $cols2 = array(0 => 0, 70);
    $endline = $rep->endLine - 20;
    $wi = ($endline - $cols2[1]) / 12;
    // 12 amount columns
    for ($i = 2; $i < 15; $i++) {
        $cols2[$i] = $cols2[$i - 1] + $wi;
    }
    $cols = $cols2;
    //----------------------------------------------------------------------------------------
    $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $headers2 = array();
    //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760);
    //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15-
    //----------------------------------------------------------------------------------------
    $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $headers = array();
    $date = begin_month($date);
    $date = add_months($date, -11);
    list($da, $mo, $yr) = explode_date_to_dmy($date);
    if ($date_system == 1) {
        list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da);
    } elseif ($date_system == 2) {
        list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da);
    }
    $headers2[0] = 'Account';
    $headers[0] = '';
    for ($i = 0; $i < 12; $i++) {
        $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1);
        // Wrap at space between month & year
        $wrap_point = strpos($header_row[$i], ' ');
        if ($wrap_point) {
            $headers2[] = substr($header_row[$i], 0, $wrap_point);
            $headers[] = substr($header_row[$i], $wrap_point + 1);
        } else {
            $headers2[] = '';
            $headers[] = $header_row[$i];
        }
        $date = add_months($date, 1);
    }
    /*
    $header_row[] = "Fiscal Year Begin";
    $header_row[] = "Fiscal YTD";
    for ($i = 12; $i < 14; $i++)
    {
       	$wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true);
       	$headers2[] = trim($wrapped_header_text[0]);
       	$headers[] = trim($wrapped_header_text[1]);
    }
    */
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)));
        }
    }
    // Company logo setting
//.........这里部分代码省略.........
开发者ID:rusli-nasir,项目名称:frontaccounting,代码行数:101,代码来源:rep_annual_balance_breakdown.php

示例12: jmktime

function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $is_dst = -1)
{
    $h = tr_num($h);
    $m = tr_num($m);
    $s = tr_num($s);
    $jm = tr_num($jm);
    $jd = tr_num($jd);
    $jy = tr_num($jy);
    if ($h == '' and $m == '' and $s == '' and $jm == '' and $jd == '' and $jy == '') {
        return mktime();
    } else {
        list($year, $month, $day) = jalali_to_gregorian($jy, $jm, $jd);
        return mktime($h, $m, $s, $month, $day, $year, $is_dst);
    }
}
开发者ID:mshahmalaki,项目名称:tahlildadeh-shop,代码行数:15,代码来源:jdf.php

示例13: jmktime

/**
 * return Unix timestamp for a date (jalali equivalent of php mktime() function)
 * @param int $hour [optional] max : 23
 * @param int $minute [optional] max : 59
 * @param int $second [optional] max: 59
 * @param int $month [optional] max: 12
 * @param int $day [optional] max: 31
 * @param int $year [optional]
 * @param int $is_dst [optional]
 * @return timestamp
 * @since 5.0.0
 */
function jmktime($hour = 0, $minute = 0, $second = 0, $month = 0, $day = 0, $year = 0, $is_dst = -1)
{
    if ($hour == 0 && $minute == 0 && $second == 0 && $month == 0 && $day == 0 && $year == 0) {
        return time();
    }
    list($year, $month, $day) = jalali_to_gregorian($year, $month, $day);
    return mktime($hour, $minute, $second, $month, $day, $year, $is_dst);
}
开发者ID:vah7id,项目名称:wp-persian-openshift,代码行数:20,代码来源:date.php

示例14: _convertDate

 /**
  * Convert given date to default (UTC) timezone
  *
  * @param string $date
  * @param string $locale
  * @return Zend_Date
  */
 protected function _convertDate($date, $locale)
 {
     try {
         if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
             require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
             list($j_y, $j_m, $j_d) = explode('/', $date);
             $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
             $date = implode('/', $gregorianlArray);
         }
         $dateObj = $this->getLocale()->date(null, null, $locale, false);
         //set default timezone for store (admin)
         $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
         //set begining of day
         $dateObj->setHour(00);
         $dateObj->setMinute(00);
         $dateObj->setSecond(00);
         //set date with applying timezone of store
         $dateObj->set($date, Zend_Date::DATE_SHORT, $locale);
         //convert store date to default date in UTC timezone without DST
         $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
         return $dateObj;
     } catch (Exception $e) {
         return null;
     }
 }
开发者ID:nitronaj,项目名称:magentofa,代码行数:32,代码来源:Date.php

示例15: ztjalali_calendar_widget

/**
 * own widget function
 */
function ztjalali_calendar_widget($shortname = TRUE, $echo = TRUE, $thisyear = 0, $thismonth = 0)
{
    global $wpdb, $posts, $wp;
    global $jdate_month_name, $ztjalali_option;
    if (isset($wp->query_vars['m'])) {
        $m_year = (int) substr($wp->query_vars['m'], 0, 4);
        $m_month = (int) substr($wp->query_vars['m'], 4, 2);
        if ($m_year < 1700) {
            list($m_year, $m_month, $tmp_day) = jalali_to_gregorian($m_year, $m_month, 15);
        }
    } elseif (isset($wp->query_vars['m'])) {
        $thisyear = (int) substr($wp->query_vars['m'], 0, 4);
    }
    if (empty($thisyear)) {
        if (isset($wp->query_vars['year'])) {
            $thisyear = (int) $wp->query_vars['year'];
        } elseif (isset($m_year)) {
            $thisyear = $m_year;
        } else {
            $thisyear = date('Y', time());
        }
    }
    if (empty($thismonth)) {
        if (isset($wp->query_vars['monthnum'])) {
            $thismonth = (int) $wp->query_vars['monthnum'];
        } elseif (isset($m_month)) {
            $thismonth = $m_month;
        } else {
            $thismonth = date('m', time());
        }
    }
    //doing: support $_GET['w']
    //  if (isset($_GET['w']))
    //    $w = '' . (int)($_GET['w']);
    //    if (!empty($w)) {
    //// We need to get the month from MySQL
    //        $thisyear = '' . (int)(substr($m, 0, 4));
    //        $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
    //        $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
    //    }
    /* doing : cache */
    $cache = array();
    $key = md5($thismonth . $thisyear);
    if ($cache = wp_cache_get('ztjalali_calendar', 'calendar')) {
        if (is_array($cache) && isset($cache[$key])) {
            if ($echo) {
                /** This filter is documented in wp-includes/general-template.php */
                echo apply_filters('ztjalali_calendar', $cache[$key]);
                return;
            } else {
                /** This filter is documented in wp-includes/general-template.php */
                return apply_filters('ztjalali_calendar', $cache[$key]);
            }
        }
    }
    if (!is_array($cache)) {
        $cache = array();
    }
    // Quick check. If we have no posts at all, abort!
    if (!$posts) {
        $gotsome = $wpdb->get_var("SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
        if (!$gotsome) {
            $cache[$key] = '';
            wp_cache_set('ztjalali_calendar', $cache, 'calendar');
            return;
        }
    }
    if ($thisyear > 1700) {
        list($thisyear, $thismonth, $thisday) = gregorian_to_jalali($thisyear, $thismonth, 1);
    }
    $unixmonth = jmktime(0, 0, 0, $thismonth, 1, $thisyear);
    $jthisyear = $thisyear;
    $jthismonth = $thismonth;
    list($thisyear, $thismonth, $jthisday) = jalali_to_gregorian($jthisyear, $jthismonth, 1);
    $last_day = jdate('t', $unixmonth, FALSE, FALSE);
    // Get the next and previous month and year with at least one post
    $startdate = date("Y:m:d", jmktime(0, 0, 0, $jthismonth, 1, $jthisyear));
    $enddate = date("Y:m:d", jmktime(23, 59, 59, $jthismonth, $last_day, $jthisyear));
    $previous = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date < '{$startdate}'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date DESC\n\t\t\tLIMIT 1");
    $next = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date > '{$enddate} 23:59:59'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date ASC\n\t\t\tLIMIT 1");
    /* translators: Calendar caption: 1: month name, 2: 4-digit year */
    $calendar_caption = _x('%1$s %2$s', 'calendar caption');
    $calendar_output = '<table id="wp-calendar" class="widget_calendar">
	<caption>' . sprintf($calendar_caption, $jdate_month_name[(int) $jthismonth], jdate('Y', $unixmonth)) . '</caption>
	<thead>
	<tr>';
    $myweek = $myshortweek = array();
    $week_begins = (int) get_option('start_of_week');
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = ztjalali_get_week_name(($wdcount + $week_begins) % 7);
        $myshortweek[] = ztjalali_get_short_week_name(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $k => $wd) {
        $day_name = true == $shortname ? $myshortweek[$k] : $wd;
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
//.........这里部分代码省略.........
开发者ID:vah7id,项目名称:wp-persian-openshift,代码行数:101,代码来源:widget_calendar.php


注:本文中的jalali_to_gregorian函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。