public function test_factory_from_TemporalAmount_null() { TestHelper::assertNullException($this, function () { Period::from(null); }); }
/** * Returns a copy of this period with the specified period subtracted. * <p> * This operates separately on the years, months and days. * No normalization is performed. * <p> * For example, "1 year, 6 months and 3 days" minus "2 years, 2 months and 2 days" * returns "-1 years, 4 months and 1 day". * <p> * The specified amount is typically an instance of {@code Period}. * Other types are interpreted using {@link Period#from(TemporalAmount)}. * <p> * This instance is immutable and unaffected by this method call. * * @param TemporalAmount $amountToSubtract the amount to subtract, not null * @return Period a {@code Period} based on this period with the requested period subtracted, not null * @throws DateTimeException if the specified amount has a non-ISO chronology or * contains an invalid unit * @throws ArithmeticException if numeric overflow occurs */ public function minusAmount(TemporalAmount $amountToSubtract) { $isoAmount = Period::from($amountToSubtract); return $this->create(Math::subtractExact($this->years, $isoAmount->years), Math::subtractExact($this->months, $isoAmount->months), Math::subtractExact($this->days, $isoAmount->days)); }