/** * For a ReducedPrinterParser, fixed width is false if the mode is strict, * otherwise it is set as for NumberPrinterParser. * @param DateTimeParseContext $context the context * @return bool if the field is fixed width * @see DateTimeFormatterBuilder#appendValueReduced(java.time.temporal.TemporalField, int, int, int) */ public function isFixedWidth(DateTimeParseContext $context) { if ($context->isStrict() == false) { return false; } return parent::isFixedWidth($context); }
/** * Appends a fixed or variable width printer-parser handling adjacent value mode. * If a PrinterParser is not active then the new PrinterParser becomes * the active PrinterParser. * Otherwise, the active PrinterParser is modified depending on the new PrinterParser. * If the new PrinterParser is fixed width and has sign style {@code NOT_NEGATIVE} * then its width is added to the active PP and * the new PrinterParser is forced to be fixed width. * If the new PrinterParser is variable width, the active PrinterParser is changed * to be fixed width and the new PrinterParser becomes the active PP. * * @param NumberPrinterParser $pp the printer-parser, not null * @return DateTimeFormatterBuilder this, for chaining, not null */ private function appendValue4(NumberPrinterParser $pp) { if ($this->active->valueParserIndex >= 0) { $activeValueParser = $this->active->valueParserIndex; // adjacent parsing mode, update setting in previous parsers $basePP = $this->active->printerParsers[$activeValueParser]; if ($pp->minWidth == $pp->maxWidth && $pp->signStyle == SignStyle::NOT_NEGATIVE()) { // Append the width to the subsequentWidth of the active parser $basePP = $basePP->withSubsequentWidth($pp->maxWidth); // Append the new parser as a fixed width $this->appendInternal($pp->withFixedWidth()); // Retain the previous active parser $this->active->valueParserIndex = $activeValueParser; } else { // Modify the active parser to be fixed width $basePP = $basePP->withFixedWidth(); // The new parser becomes the mew active parser $this->active->valueParserIndex = $this->appendInternal($pp); } // Replace the modified parser with the updated one $this->active->printerParsers[$activeValueParser] = $basePP; } else { // The new Parser becomes the active parser $this->active->valueParserIndex = $this->appendInternal($pp); } return $this; }