/** * Test if cell date value is matches a set of values defined by a set of months * * @param mixed $cellValue * @param mixed[] $monthSet * @return boolean */ private static function filterTestInPeriodDateSet($cellValue, $monthSet) { // Blank cells are always ignored, so return a FALSE if ($cellValue == '' || $cellValue === null) { return false; } if (is_numeric($cellValue)) { $dateValue = date('m', \PHPExcel\Shared\Date::excelToPHP($cellValue)); if (in_array($dateValue, $monthSet)) { return true; } } return false; }
/** * 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. * * Excel Function: * EOMONTH(dateValue,adjustmentMonths) * * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * @param int $adjustmentMonths The number of months before or after start_date. * A positive value for months yields a future date; * a negative value yields a past date. * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) { $dateValue = Functions::flattenSingleValue($dateValue); $adjustmentMonths = Functions::flattenSingleValue($adjustmentMonths); if (!is_numeric($adjustmentMonths)) { return Functions::VALUE(); } $adjustmentMonths = floor($adjustmentMonths); if (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } // Execute function $PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths + 1); $adjustDays = (int) $PHPDateObject->format('d'); $adjustDaysString = '-' . $adjustDays . ' days'; $PHPDateObject->modify($adjustDaysString); switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: return (double) \PHPExcel\Shared\Date::PHPToExcel($PHPDateObject); case Functions::RETURNDATE_PHP_NUMERIC: return (int) \PHPExcel\Shared\Date::excelToPHP(\PHPExcel\Shared\Date::PHPToExcel($PHPDateObject)); case Functions::RETURNDATE_PHP_OBJECT: return $PHPDateObject; } }