public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("y M d H m s"); $z = ZonedDateTime::ofDateTime($this->dateTime(2010, 12, 3, 11, 30), self::ZONE_PARIS())->format($f); $this->assertEquals($z, "2010 12 3 11 30 0"); }
/** * @expectedException \Celest\DateTimeParseException */ public function test_parseBest_String_parseError() { $test = DateTimeFormatter::ofPattern("yyyy-MM-dd HH:mm[XXX]"); try { $test->parseBest("2011-06-XX", TemporalQueries::fromCallable([ZonedDateTime::class, "from"]), TemporalQueries::fromCallable([LocalDateTime::class, 'from'])); } catch (DateTimeParseException $ex) { $this->assertContains("could not be parsed", $ex->getMessage()); $this->assertContains("XX", $ex->getMessage()); $this->assertEquals($ex->getParsedString(), "2011-06-XX"); $this->assertEquals($ex->getErrorIndex(), 8); throw $ex; } }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("y M"); $t = YearMonth::of(2010, 12)->format($f); $this->assertEquals($t, "2010 12"); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("y M d H m s"); $t = LocalDateTime::of(2010, 12, 3, 11, 30, 45)->format($f); $this->assertEquals($t, "2010 12 3 11 30 45"); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("y M d"); $t = LocalDate::of(2010, 12, 3)->format($f); $this->assertEquals($t, "2010 12 3"); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("y M d H m s"); $t = OffsetDateTime::of(2010, 12, 3, 11, 30, 0, 0, self::OFFSET_PONE())->format($f); $this->assertEquals($t, "2010 12 3 11 30 0"); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("M d"); $t = MonthDay::of(12, 3)->format($f); $this->assertEquals($t, "12 3"); }
public function test_parsed_toString_resolvedDateTime() { $f = DateTimeFormatter::ofPattern("yyyy-MM-dd HH:mm:ss"); $temporal = $f->parse("2010-06-30 11:30:56"); $msg = $temporal->__toString(); $this->assertContains("2010-06-30", $msg, $msg); $this->assertContains("11:30:56", $msg, $msg); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("H m s"); $t = LocalTime::of(11, 30, 45)->format($f); $this->assertEquals($t, "11 30 45"); }
public function test_pattern_String_null() { TestHelper::assertNullException($this, function () { DateTimeFormatter::ofPattern(null); }); }
public function test_format_formatter() { $f = DateTimeFormatter::ofPattern("H m s"); $t = OffsetTime::of(11, 30, 0, 0, self::OFFSET_PONE())->format($f); $this->assertEquals($t, "11 30 0"); }