示例#1
0
 /**
  * Adjusts the specified temporal object to have the same time as this object.
  * <p>
  * This returns a temporal object of the same observable type as the input
  * with the time changed to be the same as this.
  * <p>
  * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)}
  * passing {@link ChronoField#NANO_OF_DAY} as the field.
  * <p>
  * In most cases, it is clearer to reverse the calling pattern by using
  * {@link Temporal#with(TemporalAdjuster)}:
  * <pre>
  *   // these two lines are equivalent, but the second approach is recommended
  *   temporal = thisLocalTime.adjustInto(temporal);
  *   temporal = temporal.with(thisLocalTime);
  * </pre>
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param Temporal $temporal the target object to be adjusted, not null
  * @return Temporal the adjusted object, not null
  * @throws DateTimeException if unable to make the adjustment
  * @throws ArithmeticException if numeric overflow occurs
  */
 public function adjustInto(Temporal $temporal)
 {
     return $temporal->with(ChronoField::NANO_OF_DAY(), $this->toNanoOfDay());
 }
示例#2
0
 /**
  * Adjusts the specified temporal object to have the same offset, date
  * and time as this object.
  * <p>
  * This returns a temporal object of the same observable type as the input
  * with the offset, date and time changed to be the same as this.
  * <p>
  * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)}
  * three times, passing {@link ChronoField#EPOCH_DAY},
  * {@link ChronoField#NANO_OF_DAY} and {@link ChronoField#OFFSET_SECONDS} as the fields.
  * <p>
  * In most cases, it is clearer to reverse the calling pattern by using
  * {@link Temporal#with(TemporalAdjuster)}:
  * <pre>
  *   // these two lines are equivalent, but the second approach is recommended
  *   temporal = thisOffsetDateTime.adjustInto(temporal);
  *   temporal = temporal.with(thisOffsetDateTime);
  * </pre>
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param Temporal $temporal the target object to be adjusted, not null
  * @return Temporal the adjusted object, not null
  * @throws DateTimeException if unable to make the adjustment
  * @throws ArithmeticException if numeric overflow occurs
  */
 public function adjustInto(Temporal $temporal)
 {
     // OffsetDateTime is treated as three separate fields, not an instant
     // this produces the most consistent set of results overall
     // the offset is set after the date and time, as it is typically a small
     // tweak to the result, with ZonedDateTime frequently ignoring the offset
     return $temporal->with(ChronoField::EPOCH_DAY(), $this->toLocalDate()->toEpochDay())->with(ChronoField::NANO_OF_DAY(), $this->toLocalTime()->toNanoOfDay())->with(ChronoField::OFFSET_SECONDS(), $this->getOffset()->getTotalSeconds());
 }
示例#3
0
 /**
  * A query for {@code LocalTime} returning null if not found.
  * @param TemporalAccessor $temporal
  * @return null|LocalTime
  */
 public static function _localTime(TemporalAccessor $temporal)
 {
     if ($temporal->isSupported(ChronoField::NANO_OF_DAY())) {
         return LocalTime::ofNanoOfDay($temporal->getLong(ChronoField::NANO_OF_DAY()));
     }
     return null;
 }
 public function test_isSupported_TemporalField()
 {
     // TODO $this->assertEquals($this->TEST_DATE_TIME->isSupported(null), false);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::NANO_OF_SECOND()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::NANO_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MICRO_OF_SECOND()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MICRO_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MILLI_OF_SECOND()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MILLI_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::SECOND_OF_MINUTE()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::SECOND_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MINUTE_OF_HOUR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MINUTE_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::HOUR_OF_AMPM()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::CLOCK_HOUR_OF_AMPM()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::HOUR_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::CLOCK_HOUR_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::AMPM_OF_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::DAY_OF_WEEK()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::ALIGNED_DAY_OF_WEEK_IN_MONTH()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::ALIGNED_DAY_OF_WEEK_IN_YEAR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::DAY_OF_MONTH()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::DAY_OF_YEAR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::EPOCH_DAY()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::ALIGNED_WEEK_OF_MONTH()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::ALIGNED_WEEK_OF_YEAR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::MONTH_OF_YEAR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::PROLEPTIC_MONTH()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::YEAR()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::YEAR_OF_ERA()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::ERA()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::INSTANT_SECONDS()), true);
     $this->assertEquals($this->TEST_DATE_TIME->isSupported(CF::OFFSET_SECONDS()), true);
 }
示例#5
0
 private function resolveTimeFields()
 {
     // simplify fields
     if ($this->fieldValues->has(CF::CLOCK_HOUR_OF_DAY())) {
         // lenient allows anything, smart allows 0-24, strict allows 1-24
         $ch = $this->fieldValues->remove(CF::CLOCK_HOUR_OF_DAY());
         if ($this->resolverStyle == ResolverStyle::STRICT() || $this->resolverStyle == ResolverStyle::SMART() && $ch != 0) {
             CF::CLOCK_HOUR_OF_DAY()->checkValidValue($ch);
         }
         $this->updateCheckConflict3(CF::CLOCK_HOUR_OF_DAY(), CF::HOUR_OF_DAY(), $ch == 24 ? 0 : $ch);
     }
     if ($this->fieldValues->has(CF::CLOCK_HOUR_OF_AMPM())) {
         // lenient allows anything, smart allows 0-12, strict allows 1-12
         $ch = $this->fieldValues->remove(CF::CLOCK_HOUR_OF_AMPM());
         if ($this->resolverStyle == ResolverStyle::STRICT() || $this->resolverStyle == ResolverStyle::SMART() && $ch != 0) {
             CF::CLOCK_HOUR_OF_AMPM()->checkValidValue($ch);
         }
         $this->updateCheckConflict3(CF::CLOCK_HOUR_OF_AMPM(), CF::HOUR_OF_AMPM(), $ch == 12 ? 0 : $ch);
     }
     if ($this->fieldValues->has(CF::AMPM_OF_DAY()) && $this->fieldValues->has(CF::HOUR_OF_AMPM())) {
         $ap = $this->fieldValues->remove(CF::AMPM_OF_DAY());
         $hap = $this->fieldValues->remove(CF::HOUR_OF_AMPM());
         if ($this->resolverStyle == ResolverStyle::LENIENT()) {
             $this->updateCheckConflict3(CF::AMPM_OF_DAY(), CF::HOUR_OF_DAY(), Math::addExact(Math::multiplyExact($ap, 12), $hap));
         } else {
             // STRICT or SMART
             CF::AMPM_OF_DAY()->checkValidValue($ap);
             CF::HOUR_OF_AMPM()->checkValidValue($ap);
             $this->updateCheckConflict3(CF::AMPM_OF_DAY(), CF::HOUR_OF_DAY(), $ap * 12 + $hap);
         }
     }
     if ($this->fieldValues->has(CF::NANO_OF_DAY())) {
         $nod = $this->fieldValues->remove(CF::NANO_OF_DAY());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::NANO_OF_DAY()->checkValidValue($nod);
         }
         $this->updateCheckConflict3(CF::NANO_OF_DAY(), CF::HOUR_OF_DAY(), Math::div($nod, 3600000000000));
         $this->updateCheckConflict3(CF::NANO_OF_DAY(), CF::MINUTE_OF_HOUR(), Math::div($nod, 60000000000) % 60);
         $this->updateCheckConflict3(CF::NANO_OF_DAY(), CF::SECOND_OF_MINUTE(), Math::div($nod, 1000000000) % 60);
         $this->updateCheckConflict3(CF::NANO_OF_DAY(), CF::NANO_OF_SECOND(), $nod % 1000000000);
     }
     if ($this->fieldValues->has(CF::MICRO_OF_DAY())) {
         $cod = $this->fieldValues->remove(CF::MICRO_OF_DAY());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::MICRO_OF_DAY()->checkValidValue($cod);
         }
         $this->updateCheckConflict3(CF::MICRO_OF_DAY(), CF::SECOND_OF_DAY(), Math::div($cod, 1000000));
         $this->updateCheckConflict3(CF::MICRO_OF_DAY(), CF::MICRO_OF_SECOND(), $cod % 1000000);
     }
     if ($this->fieldValues->has(CF::MILLI_OF_DAY())) {
         $lod = $this->fieldValues->remove(CF::MILLI_OF_DAY());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::MILLI_OF_DAY()->checkValidValue($lod);
         }
         $this->updateCheckConflict3(CF::MILLI_OF_DAY(), CF::SECOND_OF_DAY(), Math::div($lod, 1000));
         $this->updateCheckConflict3(CF::MILLI_OF_DAY(), CF::MILLI_OF_SECOND(), $lod % 1000);
     }
     if ($this->fieldValues->has(CF::SECOND_OF_DAY())) {
         $sod = $this->fieldValues->remove(CF::SECOND_OF_DAY());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::SECOND_OF_DAY()->checkValidValue($sod);
         }
         $this->updateCheckConflict3(CF::SECOND_OF_DAY(), CF::HOUR_OF_DAY(), Math::div($sod, 3600));
         $this->updateCheckConflict3(CF::SECOND_OF_DAY(), CF::MINUTE_OF_HOUR(), Math::div($sod, 60) % 60);
         $this->updateCheckConflict3(CF::SECOND_OF_DAY(), CF::SECOND_OF_MINUTE(), $sod % 60);
     }
     if ($this->fieldValues->has(CF::MINUTE_OF_DAY())) {
         $mod = $this->fieldValues->remove(CF::MINUTE_OF_DAY());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::MINUTE_OF_DAY()->checkValidValue($mod);
         }
         $this->updateCheckConflict3(CF::MINUTE_OF_DAY(), CF::HOUR_OF_DAY(), Math::div($mod, 60));
         $this->updateCheckConflict3(CF::MINUTE_OF_DAY(), CF::MINUTE_OF_HOUR(), $mod % 60);
     }
     // combine partial second fields strictly, leaving lenient expansion to later
     if ($this->fieldValues->has(CF::NANO_OF_SECOND())) {
         $nos = $this->fieldValues->get(CF::NANO_OF_SECOND());
         if ($this->resolverStyle != ResolverStyle::LENIENT()) {
             CF::NANO_OF_SECOND()->checkValidValue($nos);
         }
         if ($this->fieldValues->has(CF::MICRO_OF_SECOND())) {
             $cos = $this->fieldValues->remove(CF::MICRO_OF_SECOND());
             if ($this->resolverStyle != ResolverStyle::LENIENT()) {
                 CF::MICRO_OF_SECOND()->checkValidValue($cos);
             }
             $nos = $cos * 1000 + $nos % 1000;
             $this->updateCheckConflict3(CF::MICRO_OF_SECOND(), CF::NANO_OF_SECOND(), $nos);
         }
         if ($this->fieldValues->has(CF::MILLI_OF_SECOND())) {
             $los = $this->fieldValues->remove(CF::MILLI_OF_SECOND());
             if ($this->resolverStyle != ResolverStyle::LENIENT()) {
                 CF::MILLI_OF_SECOND()->checkValidValue($los);
             }
             $this->updateCheckConflict3(CF::MILLI_OF_SECOND(), CF::NANO_OF_SECOND(), $los * 1000000 + $nos % 1000000);
         }
     }
     // convert to time if all four fields available (optimization)
     if ($this->fieldValues->has(CF::HOUR_OF_DAY()) && $this->fieldValues->has(CF::MINUTE_OF_HOUR()) && $this->fieldValues->has(CF::SECOND_OF_MINUTE()) && $this->fieldValues->has(CF::NANO_OF_SECOND())) {
         $hod = $this->fieldValues->remove(CF::HOUR_OF_DAY());
         $moh = $this->fieldValues->remove(CF::MINUTE_OF_HOUR());
         $som = $this->fieldValues->remove(CF::SECOND_OF_MINUTE());
         $nos = $this->fieldValues->remove(CF::NANO_OF_SECOND());
         $this->resolveTime($hod, $moh, $som, $nos);
     }
 }
 function data_fieldBased()
 {
     return [[CF::DAY_OF_WEEK(), true, false], [CF::ALIGNED_DAY_OF_WEEK_IN_MONTH(), true, false], [CF::ALIGNED_DAY_OF_WEEK_IN_YEAR(), true, false], [CF::DAY_OF_MONTH(), true, false], [CF::DAY_OF_YEAR(), true, false], [CF::EPOCH_DAY(), true, false], [CF::ALIGNED_WEEK_OF_MONTH(), true, false], [CF::ALIGNED_WEEK_OF_YEAR(), true, false], [CF::MONTH_OF_YEAR(), true, false], [CF::PROLEPTIC_MONTH(), true, false], [CF::YEAR_OF_ERA(), true, false], [CF::YEAR(), true, false], [CF::ERA(), true, false], [CF::AMPM_OF_DAY(), false, true], [CF::CLOCK_HOUR_OF_DAY(), false, true], [CF::HOUR_OF_DAY(), false, true], [CF::CLOCK_HOUR_OF_AMPM(), false, true], [CF::HOUR_OF_AMPM(), false, true], [CF::MINUTE_OF_DAY(), false, true], [CF::MINUTE_OF_HOUR(), false, true], [CF::SECOND_OF_DAY(), false, true], [CF::SECOND_OF_MINUTE(), false, true], [CF::MILLI_OF_DAY(), false, true], [CF::MILLI_OF_SECOND(), false, true], [CF::MICRO_OF_DAY(), false, true], [CF::MICRO_OF_SECOND(), false, true], [CF::NANO_OF_DAY(), false, true], [CF::NANO_OF_SECOND(), false, true]];
 }
 /**
  * @inheritdoc
  */
 public function adjustInto(Temporal $temporal)
 {
     return $temporal->with(ChronoField::EPOCH_DAY(), $this->toLocalDate()->toEpochDay())->with(ChronoField::NANO_OF_DAY(), $this->toLocalTime()->toNanoOfDay());
 }
 function data_resolveTwoToTime()
 {
     return [[ChronoField::HOUR_OF_DAY(), 8, ChronoField::MINUTE_OF_HOUR(), 6, LocalTime::of(8, 6)], [ChronoField::AMPM_OF_DAY(), 0, ChronoField::HOUR_OF_AMPM(), 5, LocalTime::of(5, 0)], [ChronoField::AMPM_OF_DAY(), 1, ChronoField::HOUR_OF_AMPM(), 5, LocalTime::of(17, 0)], [ChronoField::AMPM_OF_DAY(), 0, ChronoField::CLOCK_HOUR_OF_AMPM(), 5, LocalTime::of(5, 0)], [ChronoField::AMPM_OF_DAY(), 1, ChronoField::CLOCK_HOUR_OF_AMPM(), 5, LocalTime::of(17, 0)], [ChronoField::AMPM_OF_DAY(), 0, ChronoField::HOUR_OF_DAY(), 5, LocalTime::of(5, 0)], [ChronoField::AMPM_OF_DAY(), 1, ChronoField::HOUR_OF_DAY(), 17, LocalTime::of(17, 0)], [ChronoField::AMPM_OF_DAY(), 0, ChronoField::CLOCK_HOUR_OF_DAY(), 5, LocalTime::of(5, 0)], [ChronoField::AMPM_OF_DAY(), 1, ChronoField::CLOCK_HOUR_OF_DAY(), 17, LocalTime::of(17, 0)], [ChronoField::CLOCK_HOUR_OF_DAY(), 8, ChronoField::MINUTE_OF_HOUR(), 6, LocalTime::of(8, 6)], [ChronoField::CLOCK_HOUR_OF_DAY(), 24, ChronoField::MINUTE_OF_HOUR(), 6, LocalTime::of(0, 6)], [ChronoField::CLOCK_HOUR_OF_DAY(), 8, ChronoField::HOUR_OF_DAY(), 8, LocalTime::of(8, 0)], [ChronoField::CLOCK_HOUR_OF_DAY(), 8, ChronoField::CLOCK_HOUR_OF_AMPM(), 8, LocalTime::of(8, 0)], [ChronoField::CLOCK_HOUR_OF_DAY(), 20, ChronoField::CLOCK_HOUR_OF_AMPM(), 8, LocalTime::of(20, 0)], [ChronoField::CLOCK_HOUR_OF_DAY(), 8, ChronoField::AMPM_OF_DAY(), 0, LocalTime::of(8, 0)], [ChronoField::CLOCK_HOUR_OF_DAY(), 20, ChronoField::AMPM_OF_DAY(), 1, LocalTime::of(20, 0)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::SECOND_OF_MINUTE(), 8, LocalTime::of(10, 50, 8)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::HOUR_OF_DAY(), 10, LocalTime::of(10, 50)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::CLOCK_HOUR_OF_DAY(), 10, LocalTime::of(10, 50)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::CLOCK_HOUR_OF_AMPM(), 10, LocalTime::of(10, 50)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::AMPM_OF_DAY(), 0, LocalTime::of(10, 50)], [ChronoField::MINUTE_OF_DAY(), 650, ChronoField::MINUTE_OF_HOUR(), 50, LocalTime::of(10, 50)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::MILLI_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2000000)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::MICRO_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2000)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::NANO_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::HOUR_OF_DAY(), 1, LocalTime::of(1, 10, 50)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::MINUTE_OF_HOUR(), 10, LocalTime::of(1, 10, 50)], [ChronoField::SECOND_OF_DAY(), 3600 + 650, ChronoField::SECOND_OF_MINUTE(), 50, LocalTime::of(1, 10, 50)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::MICRO_OF_SECOND(), 2004, LocalTime::of(1, 10, 50, 2004000)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::NANO_OF_SECOND(), 2000004, LocalTime::of(1, 10, 50, 2000004)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::HOUR_OF_DAY(), 1, LocalTime::of(1, 10, 50, 2000000)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::MINUTE_OF_HOUR(), 10, LocalTime::of(1, 10, 50, 2000000)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::SECOND_OF_MINUTE(), 50, LocalTime::of(1, 10, 50, 2000000)], [ChronoField::MILLI_OF_DAY(), (3600 + 650) * 1000 + 2, ChronoField::MILLI_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2000000)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::NANO_OF_SECOND(), 2004, LocalTime::of(1, 10, 50, 2004)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::HOUR_OF_DAY(), 1, LocalTime::of(1, 10, 50, 2000)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::MINUTE_OF_HOUR(), 10, LocalTime::of(1, 10, 50, 2000)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::SECOND_OF_MINUTE(), 50, LocalTime::of(1, 10, 50, 2000)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::MILLI_OF_SECOND(), 0, LocalTime::of(1, 10, 50, 2000)], [ChronoField::MICRO_OF_DAY(), (3600 + 650) * 1000000 + 2, ChronoField::MICRO_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2000)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::HOUR_OF_DAY(), 1, LocalTime::of(1, 10, 50, 2)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::MINUTE_OF_HOUR(), 10, LocalTime::of(1, 10, 50, 2)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::SECOND_OF_MINUTE(), 50, LocalTime::of(1, 10, 50, 2)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::MILLI_OF_SECOND(), 0, LocalTime::of(1, 10, 50, 2)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::MICRO_OF_SECOND(), 0, LocalTime::of(1, 10, 50, 2)], [ChronoField::NANO_OF_DAY(), (3600 + 650) * 1000000000 + 2, ChronoField::NANO_OF_SECOND(), 2, LocalTime::of(1, 10, 50, 2)]];
 }
示例#9
0
 public function test_isSupported_TemporalField()
 {
     // TODO check
     //$this->assertEquals(TEST_2008.isSupported((TemporalField) null()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::NANO_OF_SECOND()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::NANO_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MICRO_OF_SECOND()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MICRO_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MILLI_OF_SECOND()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MILLI_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::SECOND_OF_MINUTE()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::SECOND_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MINUTE_OF_HOUR()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MINUTE_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::HOUR_OF_AMPM()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::CLOCK_HOUR_OF_AMPM()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::HOUR_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::CLOCK_HOUR_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::AMPM_OF_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::DAY_OF_WEEK()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::ALIGNED_DAY_OF_WEEK_IN_MONTH()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::ALIGNED_DAY_OF_WEEK_IN_YEAR()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::DAY_OF_MONTH()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::DAY_OF_YEAR()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::EPOCH_DAY()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::ALIGNED_WEEK_OF_MONTH()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::ALIGNED_WEEK_OF_YEAR()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::MONTH_OF_YEAR()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::PROLEPTIC_MONTH()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::YEAR()), true);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::YEAR_OF_ERA()), true);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::ERA()), true);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::INSTANT_SECONDS()), false);
     $this->assertEquals(self::$TEST_2008->isSupported(ChronoField::OFFSET_SECONDS()), false);
 }
示例#10
0
 function data_withTemporalField_outOfRange()
 {
     return [[CF::NANO_OF_SECOND(), $this->time(0, 0, 0, 0), CF::NANO_OF_SECOND()->range()->getMinimum() - 1], [CF::NANO_OF_SECOND(), $this->time(0, 0, 0, 0), CF::NANO_OF_SECOND()->range()->getMaximum() + 1], [CF::NANO_OF_DAY(), $this->time(0, 0, 0, 0), CF::NANO_OF_DAY()->range()->getMinimum() - 1], [CF::NANO_OF_DAY(), $this->time(0, 0, 0, 0), CF::NANO_OF_DAY()->range()->getMaximum() + 1], [CF::MICRO_OF_SECOND(), $this->time(0, 0, 0, 0), CF::MICRO_OF_SECOND()->range()->getMinimum() - 1], [CF::MICRO_OF_SECOND(), $this->time(0, 0, 0, 0), CF::MICRO_OF_SECOND()->range()->getMaximum() + 1], [CF::MICRO_OF_DAY(), $this->time(0, 0, 0, 0), CF::MICRO_OF_DAY()->range()->getMinimum() - 1], [CF::MICRO_OF_DAY(), $this->time(0, 0, 0, 0), CF::MICRO_OF_DAY()->range()->getMaximum() + 1], [CF::MILLI_OF_SECOND(), $this->time(0, 0, 0, 0), CF::MILLI_OF_SECOND()->range()->getMinimum() - 1], [CF::MILLI_OF_SECOND(), $this->time(0, 0, 0, 0), CF::MILLI_OF_SECOND()->range()->getMaximum() + 1], [CF::MILLI_OF_DAY(), $this->time(0, 0, 0, 0), CF::MILLI_OF_DAY()->range()->getMinimum() - 1], [CF::MILLI_OF_DAY(), $this->time(0, 0, 0, 0), CF::MILLI_OF_DAY()->range()->getMaximum() + 1], [CF::SECOND_OF_MINUTE(), $this->time(0, 0, 0, 0), CF::SECOND_OF_MINUTE()->range()->getMinimum() - 1], [CF::SECOND_OF_MINUTE(), $this->time(0, 0, 0, 0), CF::SECOND_OF_MINUTE()->range()->getMaximum() + 1], [CF::SECOND_OF_DAY(), $this->time(0, 0, 0, 0), CF::SECOND_OF_DAY()->range()->getMinimum() - 1], [CF::SECOND_OF_DAY(), $this->time(0, 0, 0, 0), CF::SECOND_OF_DAY()->range()->getMaximum() + 1], [CF::MINUTE_OF_HOUR(), $this->time(0, 0, 0, 0), CF::MINUTE_OF_HOUR()->range()->getMinimum() - 1], [CF::MINUTE_OF_HOUR(), $this->time(0, 0, 0, 0), CF::MINUTE_OF_HOUR()->range()->getMaximum() + 1], [CF::MINUTE_OF_DAY(), $this->time(0, 0, 0, 0), CF::MINUTE_OF_DAY()->range()->getMinimum() - 1], [CF::MINUTE_OF_DAY(), $this->time(0, 0, 0, 0), CF::MINUTE_OF_DAY()->range()->getMaximum() + 1], [CF::HOUR_OF_AMPM(), $this->time(0, 0, 0, 0), CF::HOUR_OF_AMPM()->range()->getMinimum() - 1], [CF::HOUR_OF_AMPM(), $this->time(0, 0, 0, 0), CF::HOUR_OF_AMPM()->range()->getMaximum() + 1], [CF::CLOCK_HOUR_OF_AMPM(), $this->time(0, 0, 0, 0), CF::CLOCK_HOUR_OF_AMPM()->range()->getMinimum() - 1], [CF::CLOCK_HOUR_OF_AMPM(), $this->time(0, 0, 0, 0), CF::CLOCK_HOUR_OF_AMPM()->range()->getMaximum() + 1], [CF::HOUR_OF_DAY(), $this->time(0, 0, 0, 0), CF::HOUR_OF_DAY()->range()->getMinimum() - 1], [CF::HOUR_OF_DAY(), $this->time(0, 0, 0, 0), CF::HOUR_OF_DAY()->range()->getMaximum() + 1], [CF::CLOCK_HOUR_OF_DAY(), $this->time(0, 0, 0, 0), CF::CLOCK_HOUR_OF_DAY()->range()->getMinimum() - 1], [CF::CLOCK_HOUR_OF_DAY(), $this->time(0, 0, 0, 0), CF::CLOCK_HOUR_OF_DAY()->range()->getMaximum() + 1], [CF::AMPM_OF_DAY(), $this->time(0, 0, 0, 0), CF::AMPM_OF_DAY()->range()->getMinimum() - 1], [CF::AMPM_OF_DAY(), $this->time(0, 0, 0, 0), CF::AMPM_OF_DAY()->range()->getMaximum() + 1]];
 }
示例#11
0
 /**
  * Adjusts the specified temporal object to have the same offset and time
  * as this object.
  * <p>
  * This returns a temporal object of the same observable type as the input
  * with the offset and time changed to be the same as this.
  * <p>
  * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)}
  * twice, passing {@link ChronoField#NANO_OF_DAY} and
  * {@link ChronoField#OFFSET_SECONDS} as the fields.
  * <p>
  * In most cases, it is clearer to reverse the calling pattern by using
  * {@link Temporal#with(TemporalAdjuster)}:
  * <pre>
  *   // these two lines are equivalent, but the second approach is recommended
  *   temporal = thisOffsetTime.adjustInto(temporal);
  *   temporal = temporal.with(thisOffsetTime);
  * </pre>
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param Temporal $temporal the target object to be adjusted, not null
  * @return Temporal the adjusted object, not null
  * @throws DateTimeException if unable to make the adjustment
  * @throws ArithmeticException if numeric overflow occurs
  */
 public function adjustInto(Temporal $temporal)
 {
     return $temporal->with(ChronoField::NANO_OF_DAY(), $this->time->toNanoOfDay())->with(ChronoField::OFFSET_SECONDS(), $this->offset->getTotalSeconds());
 }
示例#12
0
 function data_with_longTemporalField()
 {
     return [[Instant::ofEpochSecond(10, 200), CF::INSTANT_SECONDS(), 100, Instant::ofEpochSecond(100, 200), null], [Instant::ofEpochSecond(10, 200), CF::INSTANT_SECONDS(), 0, Instant::ofEpochSecond(0, 200), null], [Instant::ofEpochSecond(10, 200), CF::INSTANT_SECONDS(), -100, Instant::ofEpochSecond(-100, 200), null], [Instant::ofEpochSecond(10, 200), CF::NANO_OF_SECOND(), 100, Instant::ofEpochSecond(10, 100), null], [Instant::ofEpochSecond(10, 200), CF::NANO_OF_SECOND(), 0, Instant::ofEpochSecond(10), null], [Instant::ofEpochSecond(10, 200), CF::MICRO_OF_SECOND(), 100, Instant::ofEpochSecond(10, 100 * 1000), null], [Instant::ofEpochSecond(10, 200), CF::MICRO_OF_SECOND(), 0, Instant::ofEpochSecond(10), null], [Instant::ofEpochSecond(10, 200), CF::MILLI_OF_SECOND(), 100, Instant::ofEpochSecond(10, 100 * 1000 * 1000), null], [Instant::ofEpochSecond(10, 200), CF::MILLI_OF_SECOND(), 0, Instant::ofEpochSecond(10), null], [Instant::ofEpochSecond(10, 200), CF::NANO_OF_SECOND(), 1000000000, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MICRO_OF_SECOND(), 1000000, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MILLI_OF_SECOND(), 1000, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::SECOND_OF_MINUTE(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::SECOND_OF_DAY(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::OFFSET_SECONDS(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::NANO_OF_DAY(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MINUTE_OF_HOUR(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MINUTE_OF_DAY(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MILLI_OF_DAY(), 1, null, DateTimeException::class], [Instant::ofEpochSecond(10, 200), CF::MICRO_OF_DAY(), 1, null, DateTimeException::class]];
 }
 public static function init()
 {
     self::$FIELD_MAP = ['G' => ChronoField::ERA(), 'y' => ChronoField::YEAR_OF_ERA(), 'u' => ChronoField::YEAR(), 'Q' => IsoFields::QUARTER_OF_YEAR(), 'q' => IsoFields::QUARTER_OF_YEAR(), 'M' => ChronoField::MONTH_OF_YEAR(), 'L' => ChronoField::MONTH_OF_YEAR(), 'D' => ChronoField::DAY_OF_YEAR(), 'd' => ChronoField::DAY_OF_MONTH(), 'F' => ChronoField::ALIGNED_DAY_OF_WEEK_IN_MONTH(), 'E' => ChronoField::DAY_OF_WEEK(), 'c' => ChronoField::DAY_OF_WEEK(), 'e' => ChronoField::DAY_OF_WEEK(), 'a' => ChronoField::AMPM_OF_DAY(), 'H' => ChronoField::HOUR_OF_DAY(), 'k' => ChronoField::CLOCK_HOUR_OF_DAY(), 'K' => ChronoField::HOUR_OF_AMPM(), 'h' => ChronoField::CLOCK_HOUR_OF_AMPM(), 'm' => ChronoField::MINUTE_OF_HOUR(), 's' => ChronoField::SECOND_OF_MINUTE(), 'S' => ChronoField::NANO_OF_SECOND(), 'A' => ChronoField::MILLI_OF_DAY(), 'n' => ChronoField::NANO_OF_SECOND(), 'N' => ChronoField::NANO_OF_DAY()];
 }