/** * @param JalaliDate $jDate * @return DateTime */ public static function jalaliToDateTime(JalaliDate $jDate) { $firstDay = (new GeorgianDate(622, 3, 22))->toInteger(); $nDays = $jDate->toInteger() + $firstDay; $georgian = GeorgianDate::fromInteger($nDays); return static::georgianToDateTime($georgian); }
/** * @param JalaliDate|JDateTime $jDate * * @return DateTime */ public static function jalaliToDateTime(JalaliDate $jDate) { $firstDay = (new GeorgianDate(622, 3, 22))->toInteger(); $nDays = $jDate->toInteger() + $firstDay - 1; $georgian = GeorgianDate::fromInteger($nDays); $dateTime = static::georgianToDateTime($georgian); if ($jDate instanceof JDateTime) { $dateTime->setTime($jDate->getHour(), $jDate->getMinute(), $jDate->getSecond()); } return $dateTime; }
/** * @throws \Exception * @test * @group brute_force */ public function brute_force_test_from_and_to_integer() { for ($i = 1; $i < 1039828; $i++) { $this->assertEquals($i, GeorgianDate::fromInteger($i)->toInteger()); } }