public function test_withMonth_Month_normal() { $base = ZonedDateTime::ofDateTime(self::TEST_LOCAL_2008_06_30_11_30_59_500(), self::ZONE_0100()); $test = $base->adjust(Month::JANUARY()); $this->assertEquals($test, ZonedDateTime::ofDateTime(self::TEST_LOCAL_2008_06_30_11_30_59_500()->withMonth(1), self::ZONE_0100())); }
public function test_with_Month() { $test = YearMonth::of(2008, 6); $this->assertEquals($test->adjust(Month::JANUARY()), YearMonth::of(2008, 1)); }
/** * @group long */ public function test_now_Clock_allSecsInDay_offset() { for ($i = 0; $i < 2 * 24 * 60 * 60; $i++) { $instant = Instant::ofEpochSecond($i)->plusNanos(123456789); $clock = Clock::fixed($instant->minusSeconds(self::OFFSET_PONE()->getTotalSeconds()), self::OFFSET_PONE()); $test = LocalDateTime::nowOf($clock); $this->assertEquals($test->getYear(), 1970); $this->assertEquals($test->getMonth(), Month::JANUARY()); $this->assertEquals($test->getDayOfMonth(), $i < 24 * 60 * 60 ? 1 : 2); $this->assertEquals($test->getHour(), $i / (60 * 60) % 24); $this->assertEquals($test->getMinute(), $i / 60 % 60); $this->assertEquals($test->getSecond(), $i % 60); $this->assertEquals($test->getNano(), 123456789); } }
public function __construct() { $this->month = Month::JANUARY(); $this->time = LocalTime::MIDNIGHT(); $this->timeDefinition = TimeDefinition::WALL(); }
/** * @expectedException \Celest\DateTimeException */ public function test_factory_of_intsMonth_yearTooLow() { LocalDate::ofMonth(Integer::MIN_VALUE, Month::JANUARY(), 1); }
public function test_with_Month() { $this->assertEquals(MonthDay::of(6, 30)->with(Month::JANUARY()), MonthDay::of(1, 30)); }
public function test_enum() { $this->assertEquals(Month::valueOf("JANUARY"), Month::JANUARY()); $this->assertEquals(Month::values()[0], Month::JANUARY()); }
public function test_previousOrCurrent() { foreach (Month::values() as $month) { for ($i = 1; $i <= $month->length(false); $i++) { $date = self::date(2007, $month, $i); foreach (DayOfWeek::values() as $dow) { $test = TemporalAdjusters::previousOrSame($dow)->adjustInto($date); $this->assertSame($test->getDayOfWeek(), $dow); if ($test->getYear() == 2007) { $dayDiff = $test->getDayOfYear() - $date->getDayOfYear(); $this->assertTrue($dayDiff <= 0 && $dayDiff > -7); $this->assertEquals($date->equals($test), $date->getDayOfWeek() == $dow); } else { $this->assertFalse($date->getDayOfWeek() == $dow); $this->assertSame($month, Month::JANUARY()); $this->assertTrue($date->getDayOfMonth() < 7); $this->assertEquals($test->getYear(), 2006); $this->assertSame($test->getMonth(), Month::DECEMBER()); $this->assertTrue($test->getDayOfMonth() > 25); } } } } }