当前位置: 首页>>代码示例>>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;未经允许,请勿转载。