Esempio n. 1
0
 public function addTo(Temporal $temporal, $amount)
 {
     switch ($this) {
         case IsoFields::WEEK_BASED_YEARS():
             return $temporal->with(IsoFields::WEEK_BASED_YEAR(), Math::addExact($temporal->get(IsoFields::WEEK_BASED_YEAR()), $amount));
         case IsoFields::QUARTER_YEARS():
             // no overflow (256 is multiple of 4)
             return $temporal->plus($amount / 256, ChronoUnit::YEARS())->plus($amount % 256 * 3, ChronoUnit::MONTHS());
         default:
             throw new IllegalStateException("Unreachable");
     }
 }
Esempio n. 2
0
 public function getRangeUnit()
 {
     return IsoFields::QUARTER_YEARS();
 }
Esempio n. 3
0
 /**
  * @dataProvider data_quartersBetween
  */
 public function test_quarters_between_until(LocalDate $start, Temporal $end, $expected)
 {
     $this->assertEquals($start->until($end, IsoFields::QUARTER_YEARS()), $expected);
 }