當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Time::modify方法代碼示例

本文整理匯總了PHP中Cake\I18n\Time::modify方法的典型用法代碼示例。如果您正苦於以下問題:PHP Time::modify方法的具體用法?PHP Time::modify怎麽用?PHP Time::modify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\I18n\Time的用法示例。


在下文中一共展示了Time::modify方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testWriteFarFuture

 /**
  * test write with distant future cookies
  *
  * @return void
  */
 public function testWriteFarFuture()
 {
     $this->Cookie->configKey('Testing', 'expires', '+90 years');
     $this->Cookie->write('Testing', 'value');
     $future = new Time('now');
     $future->modify('+90 years');
     $expected = ['name' => 'Testing', 'value' => 'value', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false];
     $result = $this->Controller->response->cookie('Testing');
     $this->assertEquals($future->format('U'), $result['expire'], '', 3);
     unset($result['expire']);
     $this->assertEquals($expected, $result);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:17,代碼來源:CookieComponentTest.php

示例2: testIsThisMonth

 /**
  * testIsThisMonth method
  *
  * @return void
  */
 public function testIsThisMonth()
 {
     $time = new Time();
     $this->assertTrue($time->isThisMonth());
     $time->year = $time->year + 1;
     $this->assertFalse($time->isThisMonth());
     $time = new Time();
     $this->assertFalse($time->modify('next month')->isThisMonth());
 }
開發者ID:RogerSchmeier,項目名稱:Webtruck,代碼行數:14,代碼來源:TimeTest.php

示例3: patternevent

 public function patternevent($id = null)
 {
     $patterns = TableRegistry::get('Patterns');
     $events = TableRegistry::get('Events');
     $employee_id = $this->request->query('employee_id');
     $patternparent_id = $this->request->query('patternparentid');
     $pattern_sun = $this->request->query('patternSun');
     $pattern_mon = $this->request->query('patternMon');
     $pattern_tue = $this->request->query('patternTue');
     $pattern_wed = $this->request->query('patternWed');
     $pattern_thu = $this->request->query('patternThu');
     $pattern_fri = $this->request->query('patternFri');
     $pattern_sat = $this->request->query('patternSat');
     $pattern_id = $this->request->query('id');
     $dowMap = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
     // delete exisitng events for current patternParent
     // prior to creating events
     $events_to_delete = [$pattern_sun, $pattern_mon, $pattern_tue, $pattern_wed, $pattern_thu, $pattern_fri, $pattern_sat];
     foreach ($events_to_delete as $key => $value) {
         $events->deleteAll(['pattern_id' => $value]);
     }
     $query = $patterns->find('all', ['conditions' => ['pattern_parent_id' => $patternparent_id], 'contain' => ['Resources', 'Employees']]);
     foreach ($query as $row) {
         //debug($row->toArray());
         $eventsTable = TableRegistry::get('Events');
         // day of week
         $byweekday = $dowMap[$row['day_of_week'] - 1];
         // start date
         $patternend = new \DateTime($row['start_date']);
         // every n weeks
         $step = $row->week_of_year;
         // start date offset
         $starting_on = $row->starting_on - 1;
         foreach (getPatternDays($row['start_date'], $byweekday, $step, $starting_on, $row['end_date']) as $patternDay) {
             // create date schedule array
             $timezone = 'UTC';
             $event = $eventsTable->newEntity();
             if (!empty($query)) {
                 //loop through patterns to
                 //create all events based on current employee id and current pattern(s)
                 //save to db
                 //$count_of_leave_entitlement++;
                 //format start and end dates including adding start / end hours and minutes
                 $starthours = date('H', strtotime($row->resource->start_time));
                 $startmins = date('i', strtotime($row->resource->start_time));
                 $start = new Time($patternDay->format("Y-m-d"));
                 $start->modify('+' . $starthours . ' hours');
                 $start->modify('+' . $startmins . ' minutes');
                 $endhours = date('H', strtotime($row->resource->end_time));
                 $endmins = date('i', strtotime($row->resource->end_time));
                 $end = new Time($patternDay->format("Y-m-d"));
                 if ($row->resource->night_shift == 1) {
                     $end->modify('+ 1 day');
                 }
                 $end->modify('+' . $endhours . ' hours');
                 $end->modify('+' . $endmins . ' minutes');
                 // event model to save
                 $event->title = $row->employee->first_name[0] . ' ' . $row->employee->last_name;
                 $event->startdate = $start->format('Y-m-d H:i:s');
                 $event->enddate = $end->format('Y-m-d H:i:s');
                 $event->allDay = $row->resource->allDay;
                 $event->pattern_id = $row->id;
                 $event->resource_id = $row->resource_id;
                 $event->employee_id = $row->employee->id;
                 $event->event_type = 'pattern';
                 $event->patternparentid = $patternparent_id;
                 $eventsTable->save($event);
             } else {
                 $this->Flash->error(__('The events could not be saved. Please, try again.'));
             }
         }
     }
     $this->Flash->success(__('The events have been saved.'));
     return $this->redirect($this->referer());
     $this->autoRender = false;
 }
開發者ID:olafthelofty,項目名稱:carenta,代碼行數:76,代碼來源:EventsController.php


注:本文中的Cake\I18n\Time::modify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。