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


PHP Zend_Date::setWeekday方法代码示例

本文整理汇总了PHP中Zend_Date::setWeekday方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setWeekday方法的具体用法?PHP Zend_Date::setWeekday怎么用?PHP Zend_Date::setWeekday使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Date的用法示例。


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

示例1: _processFilter

 /**
  * @param $filter
  *
  * @return mixed
  */
 protected function _processFilter($filter)
 {
     $period = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS;
     if (array_key_exists('period', $filter)) {
         $period = intval($filter['period']);
     }
     $filter['period'] = $period;
     $fromDate = new Zend_Date();
     $toDate = new Zend_Date();
     $fromDate->setHour(23)->setMinute(59)->setSecond(59);
     $toDate->setHour(23)->setMinute(59)->setSecond(59);
     switch ($period) {
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_TODAY:
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_YESTERDAY:
             $fromDate->subDay(1);
             $toDate->subDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_WEEK:
             $firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
             if ($firstDayOfWeek === 0) {
                 $firstDayOfWeek = 7;
             }
             $fromDate->setWeekday($firstDayOfWeek);
             if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
                 $fromDate->subWeek(1);
             }
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_WEEK:
             $fromDate->subWeek(1);
             $toDate->subWeek(1);
             $firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
             if ($firstDayOfWeek === 0) {
                 $firstDayOfWeek = 7;
             }
             $fromDate->setWeekday($firstDayOfWeek);
             if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
                 $fromDate->subWeek(1);
             }
             $lastDayOfWeek = $firstDayOfWeek - 1;
             if ($lastDayOfWeek < 1) {
                 $lastDayOfWeek = 7;
             }
             $toDate->setWeekday($lastDayOfWeek);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_MONTH:
             $fromDate->setDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_MONTH:
             $fromDate->subMonth(1)->setDay(1);
             $toDate->setDay(1)->subDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SIX_MONTHS:
             $fromDate->subMonth(6);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_CUSTOM:
             $_reversed = false;
             $_now = new Zend_Date(null, 'dd/MM/y');
             try {
                 $_fromDate = new Zend_Date($filter['from_date'], 'dd/MM/y');
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "From" date value'));
                 $_fromDate = clone $_now;
             }
             try {
                 $_toDate = new Zend_Date($filter['to_date'], 'dd/MM/y');
                 if ($_fromDate->compare($_toDate) > 0) {
                     $_reversed = true;
                 }
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "To" date value'));
                 $_toDate = clone $_now;
             }
             if ($_reversed) {
                 $fromDate = $_toDate;
                 $toDate = $_fromDate;
             } else {
                 $fromDate = $_fromDate;
                 $toDate = $_toDate;
             }
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SEVEN_DAYS:
             $fromDate->subDay(6);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS:
             $fromDate->subDay(29);
             break;
     }
     $filter['from_date'] = $fromDate;
     $filter['to_date'] = $toDate;
     if (!array_key_exists('group', $filter)) {
         $filter['group'] = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::GROUP_BY_WEEK;
     }
     if (!array_key_exists('agents[]', $filter)) {
         $filter['agents[]'] = $this->_getAgentIds();
//.........这里部分代码省略.........
开发者ID:protechhelp,项目名称:gamamba,代码行数:101,代码来源:AgentController.php

示例2: testMultiByteWeekdaysShouldNotBeTruncated

 /**
  * Test for ZF-5203
  */
 public function testMultiByteWeekdaysShouldNotBeTruncated()
 {
     $date1 = new Zend_Date('pl');
     $date1->setWeekday(3);
     $this->assertEquals('ś', $date1->get(Zend_Date::WEEKDAY_NARROW));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:9,代码来源:DateTest.php

示例3: getWeek

 public function getWeek($week, $year, $locationId = null)
 {
     $zd = new Zend_Date();
     $event = new Event();
     $workshop = new Workshop();
     if ($week == 1) {
         $calData['prevWeekNum'] = 52;
         $calData['prevYear'] = $year - 1;
         $calData['nextWeekNum'] = 2;
         $calData['nextYear'] = $year;
     } else {
         if ($week == 52) {
             $calData['prevWeekNum'] = 51;
             $calData['prevYear'] = $year;
             $calData['nextWeekNum'] = 1;
             $calData['nextYear'] = $year + 1;
         } else {
             $calData['prevWeekNum'] = $week - 1;
             $calData['prevYear'] = $year;
             $calData['nextWeekNum'] = $week + 1;
             $calData['nextYear'] = $year;
         }
     }
     // go back to the current week
     $zd->setYear($year);
     $zd->setWeek($week);
     // set the weekday to sunday for the display purposes
     $zd->setWeekday("sunday");
     $month = $zd->get(Zend_Date::MONTH_SHORT);
     for ($x = 0; $x < 7; $x++) {
         $tmp = array();
         $tmp['startDay'] = $zd->get(Zend_Date::WEEKDAY_DIGIT);
         $tmp['month'] = $zd->get(Zend_Date::MONTH_SHORT);
         $tmp['day'] = $zd->get(Zend_Date::DAY_SHORT);
         $tmp['monthName'] = $zd->get(Zend_Date::MONTH_NAME);
         $tmp['monthDays'] = $zd->get(Zend_Date::MONTH_DAYS);
         $tmp['year'] = $zd->get(Zend_Date::YEAR);
         $tmp['weekNum'] = $zd->get(Zend_Date::WEEK);
         $tmp['date'] = $zd->getTimestamp();
         $calData[$x] = $tmp;
         $where = $event->getAdapter()->quoteInto('date = ?', $tmp['year'] . "-" . $tmp['month'] . "-" . $tmp['day']);
         $where .= " AND ";
         $where .= $event->getAdapter()->quoteInto('status = ?', 'open');
         if (!is_null($locationId)) {
             $where .= " AND ";
             $where .= $event->getAdapter()->quoteInto('locationId = ?', $locationId);
         }
         $calData[$x]['events'] = $event->fetchAll($where, 'startTime')->toArray();
         for ($y = 0; $y < count($calData[$x]['events']); $y++) {
             if (isset($calData[$x]['events'][$y]['workshopId'])) {
                 $tmpStart = strtotime($calData[$x]['events'][$y]['startTime']);
                 $tmpEnd = strtotime($calData[$x]['events'][$y]['endTime']);
                 $calData[$x]['events'][$y]['numMinutes'] = ($tmpEnd - $tmpStart) / 60;
                 $workshopId = $calData[$x]['events'][$y]['workshopId'];
                 $calData[$x]['events'][$y]['workshop'] = $workshop->find($workshopId)->toArray();
             }
         }
         $zd->addDay(1);
     }
     $calData['weekNum'] = $zd->get(Zend_Date::WEEK);
     $calData['year'] = $year;
     return $calData;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:63,代码来源:Calendar.php

示例4: testLoose


//.........这里部分代码省略.........
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
开发者ID:jorgenils,项目名称:zend-framework,代码行数:67,代码来源:DateTest.php

示例5: getGroupedByPeriod

 /**
  * @param array $statistics (array('2014-01-01' => 2,'2014-01-02' => 0))
  * @param int $periodType
  *
  * @return array (array('2014-01' => 2))
  */
 public function getGroupedByPeriod($statistics, $periodType)
 {
     if ($periodType == self::PERIOD_DAY_TYPE) {
         return $statistics;
     }
     ksort($statistics);
     //get first key
     $intervalDate = new Zend_Date(key($statistics), Varien_Date::DATE_INTERNAL_FORMAT);
     //reset day to 1
     $intervalDate->setDay(1);
     if ($periodType == self::PERIOD_WEEK_TYPE) {
         //for week period need set start interval like 2014-01-07
         $firstWeekDay = (int) Mage::getStoreConfig('general/locale/firstday') == 0 ? 7 : (int) Mage::getStoreConfig('general/locale/firstday');
         $intervalDate->setWeekday($firstWeekDay);
         if ($intervalDate->toString(Varien_Date::DATE_INTERNAL_FORMAT) == key($statistics)) {
             $intervalDate->addWeek(1);
         }
         $intervalDate->subDay(1);
     }
     $result = array();
     foreach ($statistics as $key => $value) {
         if (!$this->_isInPeriodInterval($intervalDate, $key, $periodType)) {
             $this->_setPeriodIntervalIndex($intervalDate, $key, $periodType);
         }
         $intervalIndex = $intervalDate->toString($this->_getPeriodIntervalDateFormat($periodType));
         if ($periodType == self::PERIOD_WEEK_TYPE) {
             $_prevWeek = clone $intervalDate;
             $_prevWeek->subWeek(1);
             $_prevWeek->addDay(1);
             $_prevWeekIndex = $_prevWeek->toString($this->_getPeriodIntervalDateFormat($periodType));
             $result[$_prevWeekIndex . '/' . $intervalIndex] = (array_key_exists($_prevWeekIndex . '/' . $intervalIndex, $result) ? $result[$_prevWeekIndex . '/' . $intervalIndex] : 0) + $this->_getValue($value);
         } else {
             $result[$intervalIndex] = (array_key_exists($intervalIndex, $result) ? $result[$intervalIndex] : 0) + $this->_getValue($value);
         }
     }
     return $result;
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:43,代码来源:Statistics.php


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