public function getDays()
 {
     if ($this->days < 0) {
         $dayBegin = null;
         $this1 = $this->begin;
         $days = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1;
         $dayBegin = datetime_utils_DateTimeMonthUtils::getMonthDay($days, datetime__DateTime_DateTime_Impl_::isLeapYear($this1));
         $dayEnd = null;
         $this2 = $this->end;
         $days1 = Std::int(($this2 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this2)) / 86400) + 1;
         $dayEnd = datetime_utils_DateTimeMonthUtils::getMonthDay($days1, datetime__DateTime_DateTime_Impl_::isLeapYear($this2));
         if ($dayBegin <= $dayEnd) {
             $this->days = $dayEnd - $dayBegin;
         } else {
             $this->days = datetime_utils_DateTimeMonthUtils::days(datetime_cores_DateTimeIntervalCore_4($this, $dayBegin, $dayEnd), datetime__DateTime_DateTime_Impl_::isLeapYear($this->begin)) - $dayBegin + $dayEnd;
         }
         $h1 = null;
         $this4 = $this->begin;
         $h1 = Std::int(($this4 - Math::ffloor($this4 / 86400) * 86400) / 3600);
         $h2 = null;
         $this5 = $this->end;
         $h2 = Std::int(($this5 - Math::ffloor($this5 / 86400) * 86400) / 3600);
         if ($h2 < $h1) {
             $this->days--;
         } else {
             if ($h2 === $h1) {
                 $m1 = null;
                 $this6 = $this->begin;
                 $m1 = Std::int(($this6 - Math::ffloor($this6 / 3600) * 3600) / 60);
                 $m2 = null;
                 $this7 = $this->end;
                 $m2 = Std::int(($this7 - Math::ffloor($this7 / 3600) * 3600) / 60);
                 if ($m2 < $m1) {
                     $this->days--;
                 } else {
                     if ($m2 === $m1 && datetime_cores_DateTimeIntervalCore_5($this, $dayBegin, $dayEnd, $h1, $h2, $m1, $m2) < datetime_cores_DateTimeIntervalCore_6($this, $dayBegin, $dayEnd, $h1, $h2, $m1, $m2)) {
                         $this->days--;
                     }
                 }
             }
         }
     }
     return $this->days;
 }
 static function toString($this1)
 {
     $Y = datetime__DateTime_DateTime_Impl_::getYear($this1);
     $M = null;
     $days = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1;
     $M = datetime_utils_DateTimeMonthUtils::getMonth($days, datetime__DateTime_DateTime_Impl_::isLeapYear($this1));
     $D = null;
     $days1 = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1;
     $D = datetime_utils_DateTimeMonthUtils::getMonthDay($days1, datetime__DateTime_DateTime_Impl_::isLeapYear($this1));
     $h = Std::int(($this1 - Math::ffloor($this1 / 86400) * 86400) / 3600);
     $m = Std::int(($this1 - Math::ffloor($this1 / 3600) * 3600) / 60);
     $s = Std::int($this1 - Math::ffloor($this1 / 60) * 60);
     return "" . _hx_string_rec($Y, "") . "-" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__4($D, $M, $Y, $h, $m, $s, $this1)) . "-" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__5($D, $M, $Y, $h, $m, $s, $this1)) . " " . _hx_string_or_null(datetime__DateTime_DateTime_Impl__6($D, $M, $Y, $h, $m, $s, $this1)) . ":" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__7($D, $M, $Y, $h, $m, $s, $this1)) . ":" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__8($D, $M, $Y, $h, $m, $s, $this1));
 }
Example #3
0
 static function addMonth($dt, $amount)
 {
     $month = null;
     $month = datetime_utils_DateTimeUtils_4($amount, $dt, $month) + $amount;
     if ($month >= 12) {
         $years = Std::int($month / 12);
         $time = datetime_utils_DateTimeUtils::addYear($dt, $years);
         $dt = $time + 62135596800.0;
         $month -= $years * 12;
     } else {
         if ($month < 0) {
             $years1 = Std::int($month / 12) - 1;
             $time1 = datetime_utils_DateTimeUtils::addYear($dt, $years1);
             $dt = $time1 + 62135596800.0;
             $month -= $years1 * 12;
         }
     }
     $isLeap = datetime__DateTime_DateTime_Impl_::isLeapYear($dt);
     $day = null;
     $value = null;
     $days1 = Std::int(($dt - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($dt)) / 86400) + 1;
     $value = datetime_utils_DateTimeMonthUtils::getMonthDay($days1, datetime__DateTime_DateTime_Impl_::isLeapYear($dt));
     $max = datetime_utils_DateTimeMonthUtils::days($month, $isLeap);
     if ($value < 1) {
         $day = 1;
     } else {
         if ($value > $max) {
             $day = $max;
         } else {
             $day = $value;
         }
     }
     return datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds($month, $isLeap) + ($day - 1) * 86400 + Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600) * 3600 + Std::int(($dt - Math::ffloor($dt / 3600) * 3600) / 60) * 60 + Std::int($dt - Math::ffloor($dt / 60) * 60);
 }