protected function setStrict($strict) { if ($strict) { $this->builder->parseStrict(); } else { $this->builder->parseLenient(); } }
public function test_parse_decoratedEmpty_lenient() { $this->builder->parseLenient()->padNext2(4, '-')->optionalStart()->appendValue(ChronoField::DAY_OF_MONTH())->optionalEnd(); $parsed = $this->builder->toFormatter()->parseUnresolved("----", $this->pos); $this->assertEquals($this->pos->getIndex(), 4); $this->assertEquals($this->pos->getErrorIndex(), -1); $this->assertNotNull($parsed); }
public function test_adjacent_lenient_fractionFollows_0digit() { // succeeds because hour/min are fixed width $f = $this->builder->parseLenient()->appendValue2(ChronoField::HOUR_OF_DAY(), 2)->appendValue2(ChronoField::MINUTE_OF_HOUR(), 2)->appendFraction(ChronoField::NANO_OF_SECOND(), 3, 3, false)->toFormatter2(Locale::UK()); $pp = new ParsePosition(0); $parsed = $f->parseUnresolved("1230", $pp); $this->assertEquals($pp->getErrorIndex(), -1); $this->assertEquals($pp->getIndex(), 4); $this->assertEquals($parsed->getLong(ChronoField::HOUR_OF_DAY()), 12); $this->assertEquals($parsed->getLong(ChronoField::MINUTE_OF_HOUR()), 30); }
public function test_parseLenient() { $this->builder->parseLenient(); $f = $this->builder->toFormatter(); $this->assertEquals($f->__toString(), "ParseStrict(false)"); }