コード例 #1
0
ファイル: IsoUnit.php プロジェクト: celest-time/prototype
 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");
     }
 }
コード例 #2
0
 public function getRangeUnit()
 {
     return IsoFields::QUARTER_YEARS();
 }
コード例 #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);
 }