예제 #1
0
 public final function atTime(LocalTime $localTime)
 {
     return parent::atTime($localTime);
 }
예제 #2
0
 public function with(TemporalField $field, $newValue)
 {
     if ($field instanceof ChronoField) {
         $f = $field;
         if ($this->getLong($f) === $newValue) {
             return $this;
         }
         switch ($f) {
             case ChronoField::PROLEPTIC_MONTH():
                 $this->getChronology()->range($f)->checkValidValue($newValue, $f);
                 return $this->plusMonths($newValue - $this->getProlepticMonth());
             case ChronoField::YEAR_OF_ERA():
             case ChronoField::YEAR():
             case ChronoField::ERA():
                 $nvalue = $this->getChronology()->range($f)->checkValidIntValue($newValue, $f);
                 switch ($f) {
                     case ChronoField::YEAR_OF_ERA():
                         return $this->withDate($this->isoDate->withYear($this->getProlepticYear() >= 1 ? $nvalue + MinguoChronology::YEARS_DIFFERENCE : 1 - $nvalue + MinguoChronology::YEARS_DIFFERENCE));
                     case ChronoField::YEAR():
                         return $this->withDate($this->isoDate->withYear($nvalue + MinguoChronology::YEARS_DIFFERENCE));
                     case ERA:
                         return $this->withDate($this->isoDate->withYear(1 - $this->getProlepticYear() + MinguoChronology::YEARS_DIFFERENCE));
                 }
         }
         return $this->withDate($this->isoDate->with($field, $newValue));
     }
     return parent::with($field, $newValue);
 }
 /**
  * @inheritdoc
  */
 public function minus($amountToSubtract, TemporalUnit $unit)
 {
     return ChronoLocalDateImpl::ensureValid($this->getChronology(), parent::minus($amountToSubtract, $unit));
 }
 /**
  * Returns a copy of this date-time with the new date and time, checking
  * to see if a new object is in fact required.
  *
  * @param Temporal $newDate the date of the new date-time, not null
  * @param LocalTime $newTime the time of the new date-time, not null
  * @return ChronoLocalDateTimeImpl the date-time, not null
  */
 private function _with(Temporal $newDate, LocalTime $newTime)
 {
     if ($this->date === $newDate && $this->time === $newTime) {
         return $this;
     }
     // Validate that the new Temporal is a ChronoLocalDate (and not something else)
     $cd = ChronoLocalDateImpl::ensureValid($this->date->getChronology(), $newDate);
     return new ChronoLocalDateTimeImpl($cd, $newTime);
 }