public function testFluentSettersWeeksAndDaysIsCumulative() { $ci = Interval::year(5)->weeksAndDays(2, 6); $this->assertInterval($ci, 5, 0, 20, 0, 0, 0); $this->assertSame(20, $ci->dayz); $this->assertSame(2, $ci->weeks); $this->assertSame(6, $ci->dayzExcludeWeeks); }
public function testAddWithNegativeDiffInterval() { $diff = Date::now()->diff(Date::now()->subWeeks(3)); $ci = Interval::create(4, 3, 6, 7, 8, 10, 11)->add($diff); $this->assertInterval($ci, 4, 3, 28, 8, 10, 11); }
public function testYearsAndMonthsInDanish() { Interval::setLocale('da'); $this->assertSame('1 år 1 måned', Interval::create(1, 1)->forHumans()); $this->assertSame('2 år 1 måned', Interval::create(2, 1)->forHumans()); }
public function testDiffFilteredNegativeWithSignWithSecondObject() { $dt1 = Date::createFromDate(2001, 1, 31); $dt2 = Date::createFromDate(1999, 1, 1); $this->assertSame(-12, $dt1->diffFiltered(Interval::month(), function (Date $date) { return $date->getYear() === 2000; }, $dt2, false)); }
/** * @expectedException \InvalidArgumentException */ public function testInstanceWithDaysThrowsException() { Interval::instance(Date::now()->diff(Date::now()->addWeeks(3))); }
public function testSecondsGetter() { $d = Interval::create(4, 5, 6, 5, 8, 9, 10); $this->assertSame(10, $d->seconds); }
/** * Get the difference in hours using a filter closure. * * @param Closure $callback * @param Date|null $dt * @param bool $abs Get the absolute of the difference * * @return int */ public function diffInHoursFiltered(Closure $callback, Date $dt = null, $abs = true) { return $this->diffFiltered(Interval::hour(), $callback, $dt, $abs); }