Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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());
 }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testInstanceWithDaysThrowsException()
 {
     Interval::instance(Date::now()->diff(Date::now()->addWeeks(3)));
 }
Exemplo n.º 6
0
 public function testSecondsGetter()
 {
     $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
     $this->assertSame(10, $d->seconds);
 }
Exemplo n.º 7
0
Arquivo: Date.php Projeto: hmlb/date
 /**
  * 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);
 }