예제 #1
0
 /**
  * @param ChronoLocalDate|null $cld
  * @throws DateTimeException
  */
 private function updateCheckConflict1($cld)
 {
     if ($this->date != null) {
         if ($cld != null && $this->date->equals($cld) == false) {
             throw new DateTimeException("Conflict found: Fields resolved to two different dates: " . $this->date . " " . $cld);
         }
     } else {
         if ($cld != null) {
             if ($this->chrono->equals($cld->getChronology()) == false) {
                 throw new DateTimeException("ChronoLocalDate must use the effective parsed chronology: " . $this->chrono);
             }
             $this->date = $cld;
         }
     }
 }
예제 #2
0
 /**
  * Casts the {@code Temporal} to {@code ChronoLocalDate} ensuring it bas the specified chronology.
  *
  * @param Chronology $chrono the chronology to check for, not null
  * @param Temporal $temporal a date-time to cast, not null
  * @return static the date-time checked and cast to {@code ChronoLocalDate}, not null
  * @throws ClassCastException if the date-time cannot be cast to ChronoLocalDate
  *  or the chronology is not equal this Chronology
  */
 static function ensureValid(Chronology $chrono, Temporal $temporal)
 {
     /** @var ChronoLocalDate $other */
     $other = $temporal;
     if ($chrono->equals($other->getChronology()) === false) {
         throw new ClassCastException("Chronology mismatch, expected: " . $chrono->getId() . ", actual: " . $other->getChronology()->getId());
     }
     return $other;
 }
 /**
  * Casts the {@code Temporal} to {@code ChronoZonedDateTimeImpl} ensuring it bas the specified chronology.
  *
  * @param Chronology $chrono the chronology to check for, not null
  * @param Temporal $temporal a date-time to cast, not null
  * @return ChronoZonedDateTimeImpl the date-time checked and cast to {@code ChronoZonedDateTimeImpl}, not null
  * @throws ClassCastException if the date-time cannot be cast to ChronoZonedDateTimeImpl
  *  or the chronology is not equal this Chronology
  */
 static function ensureValid(Chronology $chrono, Temporal $temporal)
 {
     $other = $temporal;
     // TODO cast
     if ($chrono->equals($other->getChronology()) === false) {
         throw new ClassCastException("Chronology mismatch, required: " . $chrono->getId() . ", actual: " . $other->getChronology()->getId());
     }
     return $other;
 }