You are here

private static function PHPExcel_Calculation_DateTime::_adjustDateByMonths in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php \PHPExcel_Calculation_DateTime::_adjustDateByMonths()
2 calls to PHPExcel_Calculation_DateTime::_adjustDateByMonths()
PHPExcel_Calculation_DateTime::EDATE in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php
* EDATE * * Returns the serial number that represents the date that is the indicated number of months * before or after a specified date (the start_date). * Use EDATE to calculate maturity dates or due dates that fall on the same day of the…
PHPExcel_Calculation_DateTime::EOMONTH in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php
* EOMONTH * * Returns the date value for the last day of the month that is the indicated number of months * before or after start_date. * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. * *…

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php, line 135

Class

PHPExcel_Calculation_DateTime
PHPExcel_Calculation_DateTime

Code

private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) {

  // Execute function
  $PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
  $oMonth = (int) $PHPDateObject
    ->format('m');
  $oYear = (int) $PHPDateObject
    ->format('Y');
  $adjustmentMonthsString = (string) $adjustmentMonths;
  if ($adjustmentMonths > 0) {
    $adjustmentMonthsString = '+' . $adjustmentMonths;
  }
  if ($adjustmentMonths != 0) {
    $PHPDateObject
      ->modify($adjustmentMonthsString . ' months');
  }
  $nMonth = (int) $PHPDateObject
    ->format('m');
  $nYear = (int) $PHPDateObject
    ->format('Y');
  $monthDiff = $nMonth - $oMonth + ($nYear - $oYear) * 12;
  if ($monthDiff != $adjustmentMonths) {
    $adjustDays = (int) $PHPDateObject
      ->format('d');
    $adjustDaysString = '-' . $adjustDays . ' days';
    $PHPDateObject
      ->modify($adjustDaysString);
  }
  return $PHPDateObject;
}