Exemplo n.º 1
0
 public function testCreates()
 {
     $begin = new \DateTime('2014-12-01');
     $end = new \DateTime('2014-12-31');
     $period = new Period($begin, $end);
     $this->assertEquals($begin, $period->getBegin());
     $this->assertEquals($end, $period->getEnd());
     $begin->setDate(2013, 12, 01);
     $end->setDate(2013, 12, 31);
     $this->assertEquals('2014-12-01', $period->getBegin()->format('Y-m-d'));
     $this->assertEquals('2014-12-31', $period->getEnd()->format('Y-m-d'));
     $period->getBegin()->setDate(2012, 12, 01);
     $period->getEnd()->setDate(2012, 12, 31);
     $this->assertEquals('2014-12-01', $period->getBegin()->format('Y-m-d'));
     $this->assertEquals('2014-12-31', $period->getEnd()->format('Y-m-d'));
 }
 /**
  * {@inheritdoc}
  */
 public function listAllByUserAndPeriod(User $user, Period $period)
 {
     $criteria = Criteria::create();
     $expr = Criteria::expr();
     $criteria->where($expr->andX($expr->eq('user', $user), $expr->gte('dateStarted', $period->getBegin()), $expr->lte('dateStarted', $period->getEnd())));
     $workLogs = $this->matching($criteria);
     return $workLogs;
 }
Exemplo n.º 3
0
 /**
  * @param Period $period
  * @return CalendarPeriod
  */
 public function createCalendarPeriod(Period $period)
 {
     $begin = $period->getBegin();
     $end = $period->getEnd();
     $begin->setTimezone(new \DateTimeZone($this->localeSettings->getTimeZone()));
     $end->setTimezone(new \DateTimeZone($this->localeSettings->getTimeZone()));
     return new CalendarPeriod($begin, $end);
 }
Exemplo n.º 4
0
 /**
  * Rewind the Iterator to the first element
  * @return void
  */
 public function rewind()
 {
     $this->position = clone $this->period->getBegin();
 }