public function test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches()
 {
     $mdt = MinguoDate::of(100, 6, 30);
     $mzdt = $mdt->atTime(LocalTime::NOON())->atZone(self::EUROPE_PARIS());
     $f = (new DateTimeFormatterBuilder())->appendValue(new ResolvingField($mzdt))->toFormatter();
     $f = $f->withChronology(MinguoChronology::INSTANCE());
     $accessor = $f->parse("1234567890");
     $this->assertEquals($accessor->query(TemporalQueries::localDate()), LocalDate::from($mdt));
     $this->assertEquals($accessor->query(TemporalQueries::localTime()), LocalTime::NOON());
     $this->assertEquals($accessor->query(TemporalQueries::chronology()), MinguoChronology::INSTANCE());
     $this->assertEquals($accessor->query(TemporalQueries::zoneId()), self::EUROPE_PARIS());
 }
Exemplo n.º 2
0
 public function dateFrom(TemporalAccessor $temporal)
 {
     if ($temporal instanceof MinguoDate) {
         return $temporal;
     }
     return MinguoDate::ofIsoDate(LocalDate::from($temporal));
 }
Exemplo n.º 3
0
 public function test_minguoChrono_extendedWidth()
 {
     // ISO 2021 is Minguo 110
     $f = $this->getFormatterBaseDate(ChronoField::YEAR(), 2, 4, 2021);
     $date = MinguoDate::of(109, 6, 30);
     $this->assertEquals($f->format($date), "109");
     $date = MinguoDate::of(110, 6, 30);
     $this->assertEquals($f->format($date), "10");
     $date = MinguoDate::of(199, 6, 30);
     $this->assertEquals($f->format($date), "99");
     $date = MinguoDate::of(200, 6, 30);
     $this->assertEquals($f->format($date), "00");
     $date = MinguoDate::of(209, 6, 30);
     $this->assertEquals($f->format($date), "09");
     $date = MinguoDate::of(210, 6, 30);
     $this->assertEquals($f->format($date), "210");
 }