/** * @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; }
public function createJalaliDate() { $y = $this->year ?: static::$defaultCentury + $this->yearOfCentury; if (!$this->hasNoMonth() && $this->day) { return new JalaliDate($y, $this->getMonth(), $this->day); } $firstDay = new JalaliDate($y, 1, 1); return JalaliDate::fromInteger($firstDay->toInteger() - 1 + $this->dayOfYear); }