示例#1
0
 /**
  * @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);
 }
示例#2
0
 /**
  * @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;
 }
示例#3
0
 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);
 }