morilog / jalali

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in php appliations, based on Jalali (Shamsi) DateTime class.
MIT License
852 stars 107 forks source link

Assert\InvalidArgumentException: Provided "30" is neither greater than or equal to "1" nor less than or equal to "29". #167

Open ErfanBahramali opened 6 months ago

ErfanBahramali commented 6 months ago

Hi

Apparently, there are problems in calculating the past time

Code:

use Morilog\Jalali\Jalalian;

$date = Jalalian::fromDateTime('2009-03-20 00:00:00');
$result = $date->subYears(1);

// or

(new Jalalian(1387, 12, 30))->subYears(1);

Result:

image

morilog commented 2 months ago

Its because of your input, ESFAND at 1387 has not 30 days

ErfanBahramali commented 2 months ago

Its because of your input, ESFAND at 1387 has not 30 days

OK, so 365 days before should be calculated It should not give an error