Example #1
0
 public function it_should_modify_dates()
 {
     BC::scale(18);
     $time = microtime(true);
     $start = BC::sub($time, BC::mod($time, 86400), 0);
     $end = BC::add($start, 86400);
     $this->beConstructedWith(['start' => $start, 'end' => $end]);
     $today = $this->getWrappedObject();
     $next24hrs = $today->setDate($time)->setEndDate(BC::add($time, 86400));
     $yesterday = $today->previous('1 day', 'gregorian');
     $subtracted = $this->subtractFromEnd('50', 'unix');
     $subtracted->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $subtracted->getEndDate()->shouldBeLike(BC::sub($this->getWrappedObject()->getEndDate(), 50));
     $duration = $this->setDuration('50', 'unix');
     $duration->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $duration->getEndDate()->shouldBeLike(BC::add($this->getWrappedObject()->getDate(), 50));
     $endDuration = $this->setDurationFromEnd('50', 'unix');
     $endDuration->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $endDuration->getDate()->shouldBeLike(BC::sub($this->getWrappedObject()->getEndDate(), 50));
     $merged = $this->merge($yesterday);
     $merged->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $merged->getDate()->shouldBeLike($yesterday->getDate());
     $merged->getEndDate()->shouldBeLike($this->getWrappedObject()->getEndDate());
     $this->shouldThrow('Danhunsaker\\Calends\\InvalidCompositeRangeException')->duringIntersect($yesterday);
     $intersection = $this->intersect($next24hrs);
     $intersection->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $intersection->getDate()->shouldBeLike($next24hrs->getDate());
     $intersection->getEndDate()->shouldBeLike($this->getWrappedObject()->getEndDate());
     $this->shouldThrow('Danhunsaker\\Calends\\InvalidCompositeRangeException')->duringGap($next24hrs);
     $gap = $this->gap($yesterday);
     $gap->shouldHaveType('Danhunsaker\\Calends\\Calends');
     $gap->getDate()->shouldBeLike($yesterday->getEndDate());
     $gap->getEndDate()->shouldBeLike($this->getWrappedObject()->getDate());
 }
Example #2
0
 /**
  * @Given a scale of :arg1
  */
 public function aScaleOf($arg1)
 {
     BC::scale($arg1);
     bcscale($arg1);
 }