function data_text() { return [[ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 1, "Monday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 2, "Tuesday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 3, "Wednesday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 4, "Thursday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 5, "Friday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 6, "Saturday"], [ChronoField::DAY_OF_WEEK(), TextStyle::FULL(), 7, "Sunday"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 1, "Mon"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 2, "Tue"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 3, "Wed"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 4, "Thu"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 5, "Fri"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 6, "Sat"], [ChronoField::DAY_OF_WEEK(), TextStyle::SHORT(), 7, "Sun"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 1, "1"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 2, "2"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 3, "3"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 28, "28"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 29, "29"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 30, "30"], [ChronoField::DAY_OF_MONTH(), TextStyle::FULL(), 31, "31"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 1, "1"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 2, "2"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 3, "3"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 28, "28"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 29, "29"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 30, "30"], [ChronoField::DAY_OF_MONTH(), TextStyle::SHORT(), 31, "31"], [ChronoField::MONTH_OF_YEAR(), TextStyle::FULL(), 1, "January"], [ChronoField::MONTH_OF_YEAR(), TextStyle::FULL(), 12, "December"], [ChronoField::MONTH_OF_YEAR(), TextStyle::SHORT(), 1, "Jan"], [ChronoField::MONTH_OF_YEAR(), TextStyle::SHORT(), 12, "Dec"]]; }
public function data_text() { return [[ChronoField::DAY_OF_WEEK(), 1, TextStyle::SHORT(), self::enUS(), "Mon"], [ChronoField::DAY_OF_WEEK(), 2, TextStyle::SHORT(), self::enUS(), "Tue"], [ChronoField::DAY_OF_WEEK(), 3, TextStyle::SHORT(), self::enUS(), "Wed"], [ChronoField::DAY_OF_WEEK(), 4, TextStyle::SHORT(), self::enUS(), "Thu"], [ChronoField::DAY_OF_WEEK(), 5, TextStyle::SHORT(), self::enUS(), "Fri"], [ChronoField::DAY_OF_WEEK(), 6, TextStyle::SHORT(), self::enUS(), "Sat"], [ChronoField::DAY_OF_WEEK(), 7, TextStyle::SHORT(), self::enUS(), "Sun"], [ChronoField::DAY_OF_WEEK(), 1, TextStyle::SHORT(), self::ptBR(), "seg"], [ChronoField::DAY_OF_WEEK(), 2, TextStyle::SHORT(), self::ptBR(), "ter"], [ChronoField::DAY_OF_WEEK(), 3, TextStyle::SHORT(), self::ptBR(), "qua"], [ChronoField::DAY_OF_WEEK(), 4, TextStyle::SHORT(), self::ptBR(), "qui"], [ChronoField::DAY_OF_WEEK(), 5, TextStyle::SHORT(), self::ptBR(), "sex"], [ChronoField::DAY_OF_WEEK(), 6, TextStyle::SHORT(), self::ptBR(), "sáb"], [ChronoField::DAY_OF_WEEK(), 7, TextStyle::SHORT(), self::ptBR(), "dom"], [ChronoField::DAY_OF_WEEK(), 1, TextStyle::FULL(), self::enUS(), "Monday"], [ChronoField::DAY_OF_WEEK(), 2, TextStyle::FULL(), self::enUS(), "Tuesday"], [ChronoField::DAY_OF_WEEK(), 3, TextStyle::FULL(), self::enUS(), "Wednesday"], [ChronoField::DAY_OF_WEEK(), 4, TextStyle::FULL(), self::enUS(), "Thursday"], [ChronoField::DAY_OF_WEEK(), 5, TextStyle::FULL(), self::enUS(), "Friday"], [ChronoField::DAY_OF_WEEK(), 6, TextStyle::FULL(), self::enUS(), "Saturday"], [ChronoField::DAY_OF_WEEK(), 7, TextStyle::FULL(), self::enUS(), "Sunday"], [ChronoField::DAY_OF_WEEK(), 1, TextStyle::FULL(), self::ptBR(), "segunda-feira"], [ChronoField::DAY_OF_WEEK(), 2, TextStyle::FULL(), self::ptBR(), "terça-feira"], [ChronoField::DAY_OF_WEEK(), 3, TextStyle::FULL(), self::ptBR(), "quarta-feira"], [ChronoField::DAY_OF_WEEK(), 4, TextStyle::FULL(), self::ptBR(), "quinta-feira"], [ChronoField::DAY_OF_WEEK(), 5, TextStyle::FULL(), self::ptBR(), "sexta-feira"], [ChronoField::DAY_OF_WEEK(), 6, TextStyle::FULL(), self::ptBR(), "sábado"], [ChronoField::DAY_OF_WEEK(), 7, TextStyle::FULL(), self::ptBR(), "domingo"], [ChronoField::MONTH_OF_YEAR(), 1, TextStyle::SHORT(), self::enUS(), "Jan"], [ChronoField::MONTH_OF_YEAR(), 2, TextStyle::SHORT(), self::enUS(), "Feb"], [ChronoField::MONTH_OF_YEAR(), 3, TextStyle::SHORT(), self::enUS(), "Mar"], [ChronoField::MONTH_OF_YEAR(), 4, TextStyle::SHORT(), self::enUS(), "Apr"], [ChronoField::MONTH_OF_YEAR(), 5, TextStyle::SHORT(), self::enUS(), "May"], [ChronoField::MONTH_OF_YEAR(), 6, TextStyle::SHORT(), self::enUS(), "Jun"], [ChronoField::MONTH_OF_YEAR(), 7, TextStyle::SHORT(), self::enUS(), "Jul"], [ChronoField::MONTH_OF_YEAR(), 8, TextStyle::SHORT(), self::enUS(), "Aug"], [ChronoField::MONTH_OF_YEAR(), 9, TextStyle::SHORT(), self::enUS(), "Sep"], [ChronoField::MONTH_OF_YEAR(), 10, TextStyle::SHORT(), self::enUS(), "Oct"], [ChronoField::MONTH_OF_YEAR(), 11, TextStyle::SHORT(), self::enUS(), "Nov"], [ChronoField::MONTH_OF_YEAR(), 12, TextStyle::SHORT(), self::enUS(), "Dec"], [ChronoField::MONTH_OF_YEAR(), 1, TextStyle::SHORT(), self::ptBR(), "jan"], [ChronoField::MONTH_OF_YEAR(), 2, TextStyle::SHORT(), self::ptBR(), "fev"], [ChronoField::MONTH_OF_YEAR(), 3, TextStyle::SHORT(), self::ptBR(), "mar"], [ChronoField::MONTH_OF_YEAR(), 4, TextStyle::SHORT(), self::ptBR(), "abr"], [ChronoField::MONTH_OF_YEAR(), 5, TextStyle::SHORT(), self::ptBR(), "mai"], [ChronoField::MONTH_OF_YEAR(), 6, TextStyle::SHORT(), self::ptBR(), "jun"], [ChronoField::MONTH_OF_YEAR(), 7, TextStyle::SHORT(), self::ptBR(), "jul"], [ChronoField::MONTH_OF_YEAR(), 8, TextStyle::SHORT(), self::ptBR(), "ago"], [ChronoField::MONTH_OF_YEAR(), 9, TextStyle::SHORT(), self::ptBR(), "set"], [ChronoField::MONTH_OF_YEAR(), 10, TextStyle::SHORT(), self::ptBR(), "out"], [ChronoField::MONTH_OF_YEAR(), 11, TextStyle::SHORT(), self::ptBR(), "nov"], [ChronoField::MONTH_OF_YEAR(), 12, TextStyle::SHORT(), self::ptBR(), "dez"], [ChronoField::MONTH_OF_YEAR(), 1, TextStyle::FULL(), self::enUS(), "January"], [ChronoField::MONTH_OF_YEAR(), 2, TextStyle::FULL(), self::enUS(), "February"], [ChronoField::MONTH_OF_YEAR(), 3, TextStyle::FULL(), self::enUS(), "March"], [ChronoField::MONTH_OF_YEAR(), 4, TextStyle::FULL(), self::enUS(), "April"], [ChronoField::MONTH_OF_YEAR(), 5, TextStyle::FULL(), self::enUS(), "May"], [ChronoField::MONTH_OF_YEAR(), 6, TextStyle::FULL(), self::enUS(), "June"], [ChronoField::MONTH_OF_YEAR(), 7, TextStyle::FULL(), self::enUS(), "July"], [ChronoField::MONTH_OF_YEAR(), 8, TextStyle::FULL(), self::enUS(), "August"], [ChronoField::MONTH_OF_YEAR(), 9, TextStyle::FULL(), self::enUS(), "September"], [ChronoField::MONTH_OF_YEAR(), 10, TextStyle::FULL(), self::enUS(), "October"], [ChronoField::MONTH_OF_YEAR(), 11, TextStyle::FULL(), self::enUS(), "November"], [ChronoField::MONTH_OF_YEAR(), 12, TextStyle::FULL(), self::enUS(), "December"], [ChronoField::MONTH_OF_YEAR(), 1, TextStyle::FULL(), self::ptBR(), "janeiro"], [ChronoField::MONTH_OF_YEAR(), 2, TextStyle::FULL(), self::ptBR(), "fevereiro"], [ChronoField::MONTH_OF_YEAR(), 3, TextStyle::FULL(), self::ptBR(), "março"], [ChronoField::MONTH_OF_YEAR(), 4, TextStyle::FULL(), self::ptBR(), "abril"], [ChronoField::MONTH_OF_YEAR(), 5, TextStyle::FULL(), self::ptBR(), "maio"], [ChronoField::MONTH_OF_YEAR(), 6, TextStyle::FULL(), self::ptBR(), "junho"], [ChronoField::MONTH_OF_YEAR(), 7, TextStyle::FULL(), self::ptBR(), "julho"], [ChronoField::MONTH_OF_YEAR(), 8, TextStyle::FULL(), self::ptBR(), "agosto"], [ChronoField::MONTH_OF_YEAR(), 9, TextStyle::FULL(), self::ptBR(), "setembro"], [ChronoField::MONTH_OF_YEAR(), 10, TextStyle::FULL(), self::ptBR(), "outubro"], [ChronoField::MONTH_OF_YEAR(), 11, TextStyle::FULL(), self::ptBR(), "novembro"], [ChronoField::MONTH_OF_YEAR(), 12, TextStyle::FULL(), self::ptBR(), "dezembro"], [ChronoField::AMPM_OF_DAY(), 0, TextStyle::SHORT(), self::enUS(), "AM"], [ChronoField::AMPM_OF_DAY(), 1, TextStyle::SHORT(), self::enUS(), "PM"]]; }
public function test_toString2() { $this->assertEquals("Text(MonthOfYear,SHORT)", $this->getFormatterFieldStyle(ChronoField::MONTH_OF_YEAR(), TextStyle::SHORT())->__toString()); }
public function test_getText() { $this->assertEquals(DayOfWeek::MONDAY()->getDisplayName(TextStyle::SHORT(), Locale::US()), "Mon"); }
public function test_appendText_2arg_nullRule() { TestHelper::assertNullException($this, function () { $this->builder->appendText2(null, TextStyle::SHORT()); }); }
/** * @dataProvider data_print_localized */ public function test_print_localized(TextStyle $style, LocalDateTime $ldt, ZoneOffset $offset, $expected) { $odt = OffsetDateTime::ofDateTime($ldt, $offset); $zdt = $ldt->atZone($offset); $f = (new DateTimeFormatterBuilder())->appendLocalizedOffset($style)->toFormatter(); $this->assertEquals($f->format($odt), $expected); $this->assertEquals($f->format($zdt), $expected); $this->assertEquals($f->parseQuery($expected, TemporalQueries::fromCallable([ZoneOffset::class, 'from'])), $offset); if ($style == TextStyle::FULL()) { $f = (new DateTimeFormatterBuilder())->appendPattern("ZZZZ")->toFormatter(); $this->assertEquals($f->format($odt), $expected); $this->assertEquals($f->format($zdt), $expected); $this->assertEquals($f->parseQuery($expected, TemporalQueries::fromCallable([ZoneOffset::class, 'from'])), $offset); $f = (new DateTimeFormatterBuilder())->appendPattern("OOOO")->toFormatter(); $this->assertEquals($f->format($odt), $expected); $this->assertEquals($f->format($zdt), $expected); $this->assertEquals($f->parseQuery($expected, TemporalQueries::fromCallable([ZoneOffset::class, 'from'])), $offset); } if ($style == TextStyle::SHORT()) { $f = (new DateTimeFormatterBuilder())->appendPattern("O")->toFormatter(); $this->assertEquals($f->format($odt), $expected); $this->assertEquals($f->format($zdt), $expected); $this->assertEquals($f->parseQuery($expected, TemporalQueries::fromCallable([ZoneOffset::class, 'from'])), $offset); } }
function data_preferredZones() { return [["America/New_York", "Eastern Standard Time", [], Locale::ENGLISH(), TextStyle::FULL()], ["Europe/Paris", "Central European Time", [], Locale::ENGLISH(), TextStyle::FULL()], ["CET", "Central European Time", self::preferred(), Locale::ENGLISH(), TextStyle::FULL()], ["Asia/Shanghai", "China Standard Time", [], Locale::ENGLISH(), TextStyle::FULL()], ["Asia/Taipei", "China Standard Time", self::preferred(), Locale::ENGLISH(), TextStyle::FULL()], ["America/Chicago", "CST", [], Locale::ENGLISH(), TextStyle::SHORT()], ["Asia/Taipei", "CST", self::preferred(), Locale::ENGLISH(), TextStyle::SHORT()], ["Australia/South", "ACST", self::preferred_s(), Locale::ENGLISH(), TextStyle::SHORT()], ["America/Chicago", "CDT", [], Locale::ENGLISH(), TextStyle::SHORT()], ["Asia/Shanghai", "CDT", self::preferred_s(), Locale::ENGLISH(), TextStyle::SHORT()]]; }
public function test_pattern_String() { $test = DateTimeFormatter::ofPattern("d MMM yyyy"); $fmtLocale = Locale::getDefault(); $this->assertEquals($test->format(LocalDate::of(2012, 6, 30)), "30 " . Month::JUNE()->getDisplayName(TextStyle::SHORT(), $fmtLocale) . " 2012"); $this->assertEquals($test->getLocale(), $fmtLocale, "Locale.Category.FORMAT"); }
public function test_getText() { $this->assertEquals(Month::JANUARY()->getDisplayName(TextStyle::SHORT(), Locale::US()), "Jan"); }
public function test_parse_short_lenient_number_match() { $this->setStrict(false); $pos = new ParsePosition(0); $this->assertEquals($this->getFormatterFieldStyle(ChronoField::MONTH_OF_YEAR(), TextStyle::SHORT())->parseUnresolved("1", $pos)->getLong(ChronoField::MONTH_OF_YEAR()), 1); $this->assertEquals($pos->getIndex(), 1); }
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; } }