public function testIssetReturnTrueForProperties() { $properties = array('year', 'month', 'day', 'hour', 'minute', 'second', 'dayOfWeek', 'dayOfYear', 'daysInMonth', 'timestamp', 'age', 'quarter', 'dst', 'offset', 'offsetHours', 'timezone', 'timezoneName', 'tz', 'tzName'); foreach ($properties as $property) { $this->assertTrue(isset(IntlCarbon::create(1234, 5, 6, 7, 8, 9)->{$property})); } }
public function testSecondsUntilEndOfDay() { $d = IntlCarbon::today()->endOfDay(); $this->assertSame(0, $d->secondsUntilEndOfDay()); $d = IntlCarbon::today()->endOfDay()->subSeconds(60); $this->assertSame(60, $d->secondsUntilEndOfDay()); $d = IntlCarbon::create(2014, 10, 24, 12, 34, 56); $this->assertSame(41103, $d->secondsUntilEndOfDay()); $d = IntlCarbon::create(2014, 10, 24, 0, 0, 0); $this->assertSame(86399, $d->secondsUntilEndOfDay()); }
public function testCreateFromDateWithDefaults() { $d = IntlCarbon::createFromTime(); $this->assertSame($d->timestamp, IntlCarbon::create(null, null, null, null, null, null)->timestamp); }
public function testCreateReturnsDatingInstance() { $d = IntlCarbon::createFromTimestamp(IntlCarbon::create(1975, 5, 21, 22, 32, 5)->timestamp); $this->assertIntlCarbon($d, 1975, 5, 21, 22, 32, 5); }
public function testTimestampGetter() { $d = IntlCarbon::create(); $d->setTimezone('GMT'); $this->assertSame(0, $d->setDateTime(1970, 1, 1, 0, 0, 0)->timestamp); }
public function testMaxWithInstance() { $dt1 = IntlCarbon::create(2012, 1, 1, 0, 0, 0); $dt2 = IntlCarbon::create(2099, 12, 31, 23, 59, 59)->max($dt1); $this->assertIntlCarbon($dt2, 2099, 12, 31, 23, 59, 59); }
public function testCreateWithTimeZoneString() { $d = IntlCarbon::create(2012, 1, 1, 0, 0, 0, 'Europe/London'); $this->assertIntlCarbon($d, 2012, 1, 1, 0, 0, 0); $this->assertSame('Europe/London', $d->tzName); }
public function testAverageFromLower() { $dt1 = IntlCarbon::create(2009, 12, 31, 23, 59, 59); $dt2 = IntlCarbon::create(2000, 1, 1, 1, 1, 1)->average($dt1); $this->assertIntlCarbon($dt2, 2004, 12, 31, 12, 30, 30); }
public function testToW3cString() { $d = IntlCarbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16-05:00', $d->toW3cString()); }
public function testEndOfWeek() { $d = IntlCarbon::create(1980, 8, 7, 11, 12, 13)->endOfWeek(); $this->assertIntlCarbon($d, 1980, 8, 10, 23, 59, 59); }
public function testDiffForHumansAbsoluteMonths() { IntlCarbon::setTestNow(IntlCarbon::create(2012, 1, 1)); $d = IntlCarbon::now()->subMonths(2); $this->assertSame('2 months', IntlCarbon::now()->diffForHumans($d, true)); $d = IntlCarbon::now()->addMonths(2); $this->assertSame('2 months', IntlCarbon::now()->diffForHumans($d, true)); IntlCarbon::setTestNow(); }