public function __toString()
 {
     $sb = "Localized(";
     if ($this->chr === 'Y') {
         if ($this->count == 1) {
             $sb .= "WeekBasedYear";
         } else {
             if ($this->count == 2) {
                 $sb .= "ReducedValue(WeekBasedYear,2,2,2000-01-01)";
             } else {
                 $sb .= "WeekBasedYear," . $this->count . "," . 19 . "," . ($this->count < 4 ? SignStyle::NORMAL() : SignStyle::EXCEEDS_PAD());
             }
         }
     } else {
         switch ($this->chr) {
             case 'c':
             case 'e':
                 $sb .= "DayOfWeek";
                 break;
             case 'w':
                 $sb .= "WeekOfWeekBasedYear";
                 break;
             case 'W':
                 $sb .= "WeekOfMonth";
                 break;
             default:
                 break;
         }
         $sb .= ",";
         $sb .= $this->count;
     }
     $sb .= ")";
     return $sb;
 }
 public function __toString()
 {
     if ($this->minWidth == 1 && $this->maxWidth == 19 && $this->signStyle == SignStyle::NORMAL()) {
         return "Value(" . $this->field . ")";
     }
     if ($this->minWidth == $this->maxWidth && $this->signStyle == SignStyle::NOT_NEGATIVE()) {
         return "Value(" . $this->field . "," . $this->minWidth . ")";
     }
     return "Value(" . $this->field . "," . $this->minWidth . "," . $this->maxWidth . "," . $this->signStyle . ")";
 }
 public function test_toString1()
 {
     $this->assertEquals($this->getFormatterWidth(ChronoField::HOUR_OF_DAY(), 1, 19, SignStyle::NORMAL())->__toString(), "Value(HourOfDay)");
 }
 /**
  * Create and cache a number printer parser.
  * @return NumberPrinterParser the number printer parser for this field, not null
  */
 private function numberPrinterParser()
 {
     if ($this->numberPrinterParser == null) {
         $this->numberPrinterParser = new NumberPrinterParser($this->field, 1, 19, SignStyle::NORMAL());
     }
     return $this->numberPrinterParser;
 }
 public function data_signStyle()
 {
     return [[LocalDate::of(0, 10, 2), SignStyle::ALWAYS(), null, "+00"], [LocalDate::of(2001, 10, 2), SignStyle::ALWAYS(), null, "+2001"], [LocalDate::of(-2001, 10, 2), SignStyle::ALWAYS(), null, "-2001"], [LocalDate::of(2001, 10, 2), SignStyle::NORMAL(), null, "2001"], [LocalDate::of(-2001, 10, 2), SignStyle::NORMAL(), null, "-2001"], [LocalDate::of(2001, 10, 2), SignStyle::NEVER(), null, "2001"], [LocalDate::of(-2001, 10, 2), SignStyle::NEVER(), null, "2001"], [LocalDate::of(2001, 10, 2), SignStyle::NOT_NEGATIVE(), null, "2001"], [LocalDate::of(-2001, 10, 2), SignStyle::NOT_NEGATIVE(), DateTimeException::class, ""], [LocalDate::of(0, 10, 2), SignStyle::EXCEEDS_PAD(), null, "00"], [LocalDate::of(1, 10, 2), SignStyle::EXCEEDS_PAD(), null, "01"], [LocalDate::of(-1, 10, 2), SignStyle::EXCEEDS_PAD(), null, "-01"], [LocalDate::of(20001, 10, 2), SignStyle::ALWAYS(), DateTimeException::class, ""], [LocalDate::of(20001, 10, 2), SignStyle::NORMAL(), DateTimeException::class, ""], [LocalDate::of(20001, 10, 2), SignStyle::NEVER(), DateTimeException::class, ""], [LocalDate::of(20001, 10, 2), SignStyle::EXCEEDS_PAD(), DateTimeException::class, ""], [LocalDate::of(20001, 10, 2), SignStyle::NOT_NEGATIVE(), DateTimeException::class, ""]];
 }
 public function test_parse_decoratedStartsWithPad_number()
 {
     $this->builder->padNext2(3, '-')->appendValue3(ChronoField::MONTH_OF_YEAR(), 1, 2, SignStyle::NORMAL());
     $parsed = $this->builder->toFormatter()->parseUnresolved("--2", $this->pos);
     $this->assertEquals($this->pos->getIndex(), 3);
     $this->assertEquals($this->pos->getErrorIndex(), -1);
     $this->assertEquals($parsed->isSupported(ChronoField::MONTH_OF_YEAR()), true);
     $this->assertEquals($parsed->getLong(ChronoField::MONTH_OF_YEAR()), 2);
     // +2, not -2
 }
 /**
  * @expectedException \Celest\IllegalArgumentException
  */
 public function test_appendValue_3arg_maxWidthMinWidth()
 {
     $this->builder->appendValue3(ChronoField::DAY_OF_MONTH(), 4, 2, SignStyle::NORMAL());
 }
 /**
  * @dataProvider provider_parseDigitsAdjacentLenient
  */
 public function test_parseDigitsAdjacentLenient($input, $parseLen, $parseMonth, $parsedDay)
 {
     $this->setStrict(false);
     $pos = new ParsePosition(0);
     $f = $this->builder->appendValue3(ChronoField::MONTH_OF_YEAR(), 1, 2, SignStyle::NORMAL())->appendValue2(ChronoField::DAY_OF_MONTH(), 2)->toFormatter2($this->locale)->withDecimalStyle($this->decimalStyle);
     $parsed = $f->parseUnresolved($input, $pos);
     if ($pos->getErrorIndex() !== -1) {
         $this->assertEquals($pos->getErrorIndex(), $parseLen);
     } else {
         $this->assertEquals($pos->getIndex(), $parseLen);
         $this->assertEquals($parsed->getLong(ChronoField::MONTH_OF_YEAR()), $parseMonth);
         $this->assertEquals($parsed->getLong(ChronoField::DAY_OF_MONTH()), $parsedDay);
         $this->assertEquals($parsed->query(TemporalQueries::chronology()), null);
         $this->assertEquals($parsed->query(TemporalQueries::zoneId()), null);
     }
 }
 public function test_appendValueReduced_subsequent_parse()
 {
     $this->builder->appendValue3(CF::MONTH_OF_YEAR(), 1, 2, SignStyle::NORMAL())->appendValueReduced(CF::YEAR(), 2, 2, 2000);
     $f = $this->builder->toFormatter();
     $this->assertEquals($f->__toString(), "Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)");
     $ppos = new ParsePosition(0);
     $parsed = $f->parseUnresolved("123", $ppos);
     $this->assertNotNull($parsed, "Parse failed: " . $ppos->__toString());
     $this->assertEquals($parsed->getLong(CF::MONTH_OF_YEAR()), 1);
     $this->assertEquals($parsed->getLong(CF::YEAR()), 2023);
 }
 private function parseField($cur, $count, TemporalField $field)
 {
     $standalone = false;
     switch ($cur) {
         case 'u':
         case 'y':
             if ($count === 2) {
                 $this->appendValueReduced2($field, 2, 2, ReducedPrinterParser::BASE_DATE());
             } else {
                 if ($count < 4) {
                     $this->appendValue3($field, $count, 19, SignStyle::NORMAL());
                 } else {
                     $this->appendValue3($field, $count, 19, SignStyle::EXCEEDS_PAD());
                 }
             }
             break;
             /** @noinspection PhpMissingBreakStatementInspection */
         /** @noinspection PhpMissingBreakStatementInspection */
         case 'c':
             if ($count === 2) {
                 throw new IllegalArgumentException("Invalid pattern \"cc\"");
             }
             /*fallthrough*/
         /*fallthrough*/
         case 'L':
             /** @noinspection PhpMissingBreakStatementInspection */
         /** @noinspection PhpMissingBreakStatementInspection */
         case 'q':
             $standalone = true;
             /*fallthrough*/
         /*fallthrough*/
         case 'M':
         case 'Q':
         case 'E':
         case 'e':
             switch ($count) {
                 case 1:
                 case 2:
                     if ($cur == 'c' || $cur == 'e') {
                         $this->appendInternal(new WeekBasedFieldPrinterParser($cur, $count));
                     } else {
                         if ($cur == 'E') {
                             $this->appendText2($field, TextStyle::SHORT());
                         } else {
                             if ($count === 1) {
                                 $this->appendValue($field);
                             } else {
                                 $this->appendValue2($field, 2);
                             }
                         }
                     }
                     break;
                 case 3:
                     $this->appendText2($field, $standalone ? TextStyle::SHORT_STANDALONE() : TextStyle::SHORT());
                     break;
                 case 4:
                     $this->appendText2($field, $standalone ? TextStyle::FULL_STANDALONE() : TextStyle::FULL());
                     break;
                 case 5:
                     $this->appendText2($field, $standalone ? TextStyle::NARROW_STANDALONE() : TextStyle::NARROW());
                     break;
                 default:
                     throw new IllegalArgumentException("Too many pattern letters: " . $cur);
             }
             break;
         case 'a':
             if ($count === 1) {
                 $this->appendText2($field, TextStyle::SHORT());
             } else {
                 throw new IllegalArgumentException("Too many pattern letters: " . $cur);
             }
             break;
         case 'G':
             switch ($count) {
                 case 1:
                 case 2:
                 case 3:
                     $this->appendText2($field, TextStyle::SHORT());
                     break;
                 case 4:
                     $this->appendText2($field, TextStyle::FULL());
                     break;
                 case 5:
                     $this->appendText2($field, TextStyle::NARROW());
                     break;
                 default:
                     throw new IllegalArgumentException("Too many pattern letters: " . $cur);
             }
             break;
         case 'S':
             $this->appendFraction(ChronoField::NANO_OF_SECOND(), $count, $count, false);
             break;
         case 'F':
             if ($count == 1) {
                 $this->appendValue($field);
             } else {
                 throw new IllegalArgumentException("Too many pattern letters: " . $cur);
             }
             break;
         case 'd':
         case 'h':
         case 'H':
         case 'k':
         case 'K':
         case 'm':
         case 's':
             if ($count === 1) {
                 $this->appendValue($field);
             } else {
                 if ($count === 2) {
                     $this->appendValue2($field, $count);
                 } else {
                     throw new IllegalArgumentException("Too many pattern letters: " . $cur);
                 }
             }
             break;
         case 'D':
             if ($count == 1) {
                 $this->appendValue($field);
             } else {
                 if ($count <= 3) {
                     $this->appendValue2($field, $count);
                 } else {
                     throw new IllegalArgumentException("Too many pattern letters: " . $cur);
                 }
             }
             break;
         default:
             if ($count == 1) {
                 $this->appendValue($field);
             } else {
                 $this->appendValue2($field, $count);
             }
             break;
     }
 }