How to use end method of value class

Best Atoum code snippet using value.end

DateTime.php

Source:DateTime.php Github

copy

Full Screen

...42class PHPExcel_Calculation_DateTime {43 public static function _isLeapYear($year) {44 return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));45 } // function _isLeapYear()46 private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) {47 if ($startDay == 31) {48 --$startDay;49 } elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::_isLeapYear($startYear))))) {50 $startDay = 30;51 }52 if ($endDay == 31) {53 if ($methodUS && $startDay != 30) {54 $endDay = 1;55 if ($endMonth == 12) {56 ++$endYear;57 $endMonth = 1;58 } else {59 ++$endMonth;60 }61 } else {62 $endDay = 30;63 }64 }65 return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;66 } // function _dateDiff360()67 /**68 * _getDateValue69 *70 * @param string $dateValue71 * @return mixed Excel date/time serial value, or string if error72 */73 public static function _getDateValue($dateValue) {74 if (!is_numeric($dateValue)) {75 if ((is_string($dateValue)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {76 return PHPExcel_Calculation_Functions::VALUE();77 }78 if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) {79 $dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue);80 } else {81 $saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();82 PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);83 $dateValue = self::DATEVALUE($dateValue);84 PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType);85 }86 }87 return $dateValue;88 } // function _getDateValue()89 /**90 * _getTimeValue91 *92 * @param string $timeValue93 * @return mixed Excel date/time serial value, or string if error94 */95 private static function _getTimeValue($timeValue) {96 $saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();97 PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);98 $timeValue = self::TIMEVALUE($timeValue);99 PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType);100 return $timeValue;101 } // function _getTimeValue()102 private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) {103 // Execute function104 $PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);105 $oMonth = (int) $PHPDateObject->format('m');106 $oYear = (int) $PHPDateObject->format('Y');107 $adjustmentMonthsString = (string) $adjustmentMonths;108 if ($adjustmentMonths > 0) {109 $adjustmentMonthsString = '+'.$adjustmentMonths;110 }111 if ($adjustmentMonths != 0) {112 $PHPDateObject->modify($adjustmentMonthsString.' months');113 }114 $nMonth = (int) $PHPDateObject->format('m');115 $nYear = (int) $PHPDateObject->format('Y');116 $monthDiff = ($nMonth - $oMonth) + (($nYear - $oYear) * 12);117 if ($monthDiff != $adjustmentMonths) {118 $adjustDays = (int) $PHPDateObject->format('d');119 $adjustDaysString = '-'.$adjustDays.' days';120 $PHPDateObject->modify($adjustDaysString);121 }122 return $PHPDateObject;123 } // function _adjustDateByMonths()124 /**125 * DATETIMENOW126 *127 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,128 * depending on the value of the ReturnDateType flag129 */130 public static function DATETIMENOW() {131 $saveTimeZone = date_default_timezone_get();132 date_default_timezone_set('UTC');133 $retValue = False;134 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {135 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :136 $retValue = (float) PHPExcel_Shared_Date::PHPToExcel(time());137 break;138 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :139 $retValue = (integer) time();140 break;141 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :142 $retValue = new DateTime();143 break;144 }145 date_default_timezone_set($saveTimeZone);146 return $retValue;147 } // function DATETIMENOW()148 /**149 * DATENOW150 *151 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,152 * depending on the value of the ReturnDateType flag153 */154 public static function DATENOW() {155 $saveTimeZone = date_default_timezone_get();156 date_default_timezone_set('UTC');157 $retValue = False;158 $excelDateTime = floor(PHPExcel_Shared_Date::PHPToExcel(time()));159 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {160 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :161 $retValue = (float) $excelDateTime;162 break;163 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :164 $retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime) - 3600;165 break;166 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :167 $retValue = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateTime);168 break;169 }170 date_default_timezone_set($saveTimeZone);171 return $retValue;172 } // function DATENOW()173 /**174 * DATE175 *176 * @param long $year177 * @param long $month178 * @param long $day179 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,180 * depending on the value of the ReturnDateType flag181 */182 public static function DATE($year = 0, $month = 1, $day = 1) {183 $year = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($year);184 $month = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($month);185 $day = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($day);186 $baseYear = PHPExcel_Shared_Date::getExcelCalendar();187 // Validate parameters188 if ($year < ($baseYear-1900)) {189 return PHPExcel_Calculation_Functions::NaN();190 }191 if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {192 return PHPExcel_Calculation_Functions::NaN();193 }194 if (($year < $baseYear) && ($year >= ($baseYear-1900))) {195 $year += 1900;196 }197 if ($month < 1) {198 // Handle year/month adjustment if month < 1199 --$month;200 $year += ceil($month / 12) - 1;201 $month = 13 - abs($month % 12);202 } elseif ($month > 12) {203 // Handle year/month adjustment if month > 12204 $year += floor($month / 12);205 $month = ($month % 12);206 }207 // Re-validate the year parameter after adjustments208 if (($year < $baseYear) || ($year >= 10000)) {209 return PHPExcel_Calculation_Functions::NaN();210 }211 // Execute function212 $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day);213 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {214 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :215 return (float) $excelDateValue;216 break;217 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :218 return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);219 break;220 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :221 return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);222 break;223 }224 } // function DATE()225 /**226 * TIME227 *228 * @param long $hour229 * @param long $minute230 * @param long $second231 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,232 * depending on the value of the ReturnDateType flag233 */234 public static function TIME($hour = 0, $minute = 0, $second = 0) {235 $hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour);236 $minute = PHPExcel_Calculation_Functions::flattenSingleValue($minute);237 $second = PHPExcel_Calculation_Functions::flattenSingleValue($second);238 if ($hour == '') { $hour = 0; }239 if ($minute == '') { $minute = 0; }240 if ($second == '') { $second = 0; }241 if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {242 return PHPExcel_Calculation_Functions::VALUE();243 }244 $hour = (integer) $hour;245 $minute = (integer) $minute;246 $second = (integer) $second;247 if ($second < 0) {248 $minute += floor($second / 60);249 $second = 60 - abs($second % 60);250 if ($second == 60) { $second = 0; }251 } elseif ($second >= 60) {252 $minute += floor($second / 60);253 $second = $second % 60;254 }255 if ($minute < 0) {256 $hour += floor($minute / 60);257 $minute = 60 - abs($minute % 60);258 if ($minute == 60) { $minute = 0; }259 } elseif ($minute >= 60) {260 $hour += floor($minute / 60);261 $minute = $minute % 60;262 }263 if ($hour > 23) {264 $hour = $hour % 24;265 } elseif ($hour < 0) {266 return PHPExcel_Calculation_Functions::NaN();267 }268 // Execute function269 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {270 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :271 $date = 0;272 $calendar = PHPExcel_Shared_Date::getExcelCalendar();273 if ($calendar != PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900) {274 $date = 1;275 }276 return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);277 break;278 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :279 return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour-1, $minute, $second)); // -2147468400; // -2147472000 + 3600280 break;281 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :282 $dayAdjust = 0;283 if ($hour < 0) {284 $dayAdjust = floor($hour / 24);285 $hour = 24 - abs($hour % 24);286 if ($hour == 24) { $hour = 0; }287 } elseif ($hour >= 24) {288 $dayAdjust = floor($hour / 24);289 $hour = $hour % 24;290 }291 $phpDateObject = new DateTime('1900-01-01 '.$hour.':'.$minute.':'.$second);292 if ($dayAdjust != 0) {293 $phpDateObject->modify($dayAdjust.' days');294 }295 return $phpDateObject;296 break;297 }298 } // function TIME()299 /**300 * DATEVALUE301 *302 * @param string $dateValue303 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,304 * depending on the value of the ReturnDateType flag305 */306 public static function DATEVALUE($dateValue = 1) {307 $dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue),'"');308 // Strip any ordinals because they're allowed in Excel (English only)309 $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue);310 // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)311 $dateValue = str_replace(array('/','.','-',' '),array(' ',' ',' ',' '),$dateValue);312 $yearFound = false;313 $t1 = explode(' ',$dateValue);314 foreach($t1 as &$t) {315 if ((is_numeric($t)) && ($t > 31)) {316 if ($yearFound) {317 return PHPExcel_Calculation_Functions::VALUE();318 } else {319 if ($t < 100) { $t += 1900; }320 $yearFound = true;321 }322 }323 }324 if ((count($t1) == 1) && (strpos($t,':') != false)) {325 // We've been fed a time value without any date326 return 0.0;327 } elseif (count($t1) == 2) {328 // We only have two parts of the date: either day/month or month/year329 if ($yearFound) {330 array_unshift($t1,1);331 } else {332 array_push($t1,date('Y'));333 }334 }335 unset($t);336 $dateValue = implode(' ',$t1);337 $PHPDateArray = date_parse($dateValue);338 if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {339 $testVal1 = strtok($dateValue,'- ');340 if ($testVal1 !== False) {341 $testVal2 = strtok('- ');342 if ($testVal2 !== False) {343 $testVal3 = strtok('- ');344 if ($testVal3 === False) {345 $testVal3 = strftime('%Y');346 }347 } else {348 return PHPExcel_Calculation_Functions::VALUE();349 }350 } else {351 return PHPExcel_Calculation_Functions::VALUE();352 }353 $PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);354 if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {355 $PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);356 if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {357 return PHPExcel_Calculation_Functions::VALUE();358 }359 }360 }361 if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {362 // Execute function363 if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }364 if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }365 if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }366 $excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));367 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {368 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :369 return (float) $excelDateValue;370 break;371 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :372 return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);373 break;374 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :375 return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');376 break;377 }378 }379 return PHPExcel_Calculation_Functions::VALUE();380 } // function DATEVALUE()381 /**382 * TIMEVALUE383 *384 * @param string $timeValue385 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,386 * depending on the value of the ReturnDateType flag387 */388 public static function TIMEVALUE($timeValue) {389 $timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue),'"');390 $timeValue = str_replace(array('/','.'),array('-','-'),$timeValue);391 $PHPDateArray = date_parse($timeValue);392 if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {393 if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {394 $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);395 } else {396 $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1;397 }398 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {399 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :400 return (float) $excelDateValue;401 break;402 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :403 return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;404 break;405 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :406 return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);407 break;408 }409 }410 return PHPExcel_Calculation_Functions::VALUE();411 } // function TIMEVALUE()412 /**413 * DATEDIF414 *415 * @param long $startDate Excel date serial value or a standard date string416 * @param long $endDate Excel date serial value or a standard date string417 * @param string $unit418 * @return long Interval between the dates419 */420 public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') {421 $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);422 $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);423 $unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));424 if (is_string($startDate = self::_getDateValue($startDate))) {425 return PHPExcel_Calculation_Functions::VALUE();426 }427 if (is_string($endDate = self::_getDateValue($endDate))) {428 return PHPExcel_Calculation_Functions::VALUE();429 }430 // Validate parameters431 if ($startDate >= $endDate) {432 return PHPExcel_Calculation_Functions::NaN();433 }434 // Execute function435 $difference = $endDate - $startDate;436 $PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);437 $startDays = $PHPStartDateObject->format('j');438 $startMonths = $PHPStartDateObject->format('n');439 $startYears = $PHPStartDateObject->format('Y');440 $PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);441 $endDays = $PHPEndDateObject->format('j');442 $endMonths = $PHPEndDateObject->format('n');443 $endYears = $PHPEndDateObject->format('Y');444 $retVal = PHPExcel_Calculation_Functions::NaN();445 switch ($unit) {446 case 'D':447 $retVal = intval($difference);448 break;449 case 'M':450 $retVal = intval($endMonths - $startMonths) + (intval($endYears - $startYears) * 12);451 // We're only interested in full months452 if ($endDays < $startDays) {453 --$retVal;454 }455 break;456 case 'Y':457 $retVal = intval($endYears - $startYears);458 // We're only interested in full months459 if ($endMonths < $startMonths) {460 --$retVal;461 } elseif (($endMonths == $startMonths) && ($endDays < $startDays)) {462 --$retVal;463 }464 break;465 case 'MD':466 if ($endDays < $startDays) {467 $retVal = $endDays;468 $PHPEndDateObject->modify('-'.$endDays.' days');469 $adjustDays = $PHPEndDateObject->format('j');470 if ($adjustDays > $startDays) {471 $retVal += ($adjustDays - $startDays);472 }473 } else {474 $retVal = $endDays - $startDays;475 }476 break;477 case 'YM':478 $retVal = intval($endMonths - $startMonths);479 if ($retVal < 0) $retVal = 12 + $retVal;480 // We're only interested in full months481 if ($endDays < $startDays) {482 --$retVal;483 }484 break;485 case 'YD':486 $retVal = intval($difference);487 if ($endYears > $startYears) {488 while ($endYears > $startYears) {489 $PHPEndDateObject->modify('-1 year');490 $endYears = $PHPEndDateObject->format('Y');491 }492 $retVal = $PHPEndDateObject->format('z') - $PHPStartDateObject->format('z');493 if ($retVal < 0) { $retVal += 365; }494 }495 break;496 }497 return $retVal;498 } // function DATEDIF()499 /**500 * DAYS360501 *502 * @param long $startDate Excel date serial value or a standard date string503 * @param long $endDate Excel date serial value or a standard date string504 * @param boolean $method US or European Method505 * @return long PHP date/time serial506 */507 public static function DAYS360($startDate = 0, $endDate = 0, $method = false) {508 $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);509 $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);510 if (is_string($startDate = self::_getDateValue($startDate))) {511 return PHPExcel_Calculation_Functions::VALUE();512 }513 if (is_string($endDate = self::_getDateValue($endDate))) {514 return PHPExcel_Calculation_Functions::VALUE();515 }516 // Execute function517 $PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);518 $startDay = $PHPStartDateObject->format('j');519 $startMonth = $PHPStartDateObject->format('n');520 $startYear = $PHPStartDateObject->format('Y');521 $PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);522 $endDay = $PHPEndDateObject->format('j');523 $endMonth = $PHPEndDateObject->format('n');524 $endYear = $PHPEndDateObject->format('Y');525 return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);526 } // function DAYS360()527 /**528 * YEARFRAC529 *530 * Calculates the fraction of the year represented by the number of whole days between two dates (the start_date and the531 * end_date). Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations532 * to assign to a specific term.533 *534 * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string535 * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string536 * @param integer $method Method used for the calculation537 * 0 or omitted US (NASD) 30/360538 * 1 Actual/actual539 * 2 Actual/360540 * 3 Actual/365541 * 4 European 30/360542 * @return float fraction of the year543 */544 public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) {545 $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);546 $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);547 $method = PHPExcel_Calculation_Functions::flattenSingleValue($method);548 if (is_string($startDate = self::_getDateValue($startDate))) {549 return PHPExcel_Calculation_Functions::VALUE();550 }551 if (is_string($endDate = self::_getDateValue($endDate))) {552 return PHPExcel_Calculation_Functions::VALUE();553 }554 if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {555 switch($method) {556 case 0 :557 return self::DAYS360($startDate,$endDate) / 360;558 break;559 case 1 :560 $days = self::DATEDIF($startDate,$endDate);561 $startYear = self::YEAR($startDate);562 $endYear = self::YEAR($endDate);563 $years = $endYear - $startYear + 1;564 $leapDays = 0;565 if ($years == 1) {566 if (self::_isLeapYear($endYear)) {567 $startMonth = self::MONTHOFYEAR($startDate);568 $endMonth = self::MONTHOFYEAR($endDate);569 $endDay = self::DAYOFMONTH($endDate);570 if (($startMonth < 3) ||571 (($endMonth * 100 + $endDay) >= (2 * 100 + 29))) {572 $leapDays += 1;573 }574 }575 } else {576 for($year = $startYear; $year <= $endYear; ++$year) {577 if ($year == $startYear) {578 $startMonth = self::MONTHOFYEAR($startDate);579 $startDay = self::DAYOFMONTH($startDate);580 if ($startMonth < 3) {581 $leapDays += (self::_isLeapYear($year)) ? 1 : 0;582 }583 } elseif($year == $endYear) {584 $endMonth = self::MONTHOFYEAR($endDate);585 $endDay = self::DAYOFMONTH($endDate);586 if (($endMonth * 100 + $endDay) >= (2 * 100 + 29)) {587 $leapDays += (self::_isLeapYear($year)) ? 1 : 0;588 }589 } else {590 $leapDays += (self::_isLeapYear($year)) ? 1 : 0;591 }592 }593 if ($years == 2) {594 if (($leapDays == 0) && (self::_isLeapYear($startYear)) && ($days > 365)) {595 $leapDays = 1;596 } elseif ($days < 366) {597 $years = 1;598 }599 }600 $leapDays /= $years;601 }602 return $days / (365 + $leapDays);603 break;604 case 2 :605 return self::DATEDIF($startDate,$endDate) / 360;606 break;607 case 3 :608 return self::DATEDIF($startDate,$endDate) / 365;609 break;610 case 4 :611 return self::DAYS360($startDate,$endDate,True) / 360;612 break;613 }614 }615 return PHPExcel_Calculation_Functions::VALUE();616 } // function YEARFRAC()617 /**618 * NETWORKDAYS619 *620 * @param mixed Start date621 * @param mixed End date622 * @param array of mixed Optional Date Series623 * @return long Interval between the dates624 */625 public static function NETWORKDAYS($startDate,$endDate) {626 // Retrieve the mandatory start and end date that are referenced in the function definition627 $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);628 $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);629 // Flush the mandatory start and end date that are referenced in the function definition, and get the optional days630 $dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());631 array_shift($dateArgs);632 array_shift($dateArgs);633 // Validate the start and end dates634 if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {635 return PHPExcel_Calculation_Functions::VALUE();636 }637 $startDate = (float) floor($startDate);638 if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {639 return PHPExcel_Calculation_Functions::VALUE();640 }641 $endDate = (float) floor($endDate);642 if ($sDate > $eDate) {643 $startDate = $eDate;644 $endDate = $sDate;645 }646 // Execute function647 $startDoW = 6 - self::DAYOFWEEK($startDate,2);648 if ($startDoW < 0) { $startDoW = 0; }649 $endDoW = self::DAYOFWEEK($endDate,2);650 if ($endDoW >= 6) { $endDoW = 0; }651 $wholeWeekDays = floor(($endDate - $startDate) / 7) * 5;652 $partWeekDays = $endDoW + $startDoW;653 if ($partWeekDays > 5) {654 $partWeekDays -= 5;655 }656 // Test any extra holiday parameters657 $holidayCountedArray = array();658 foreach ($dateArgs as $holidayDate) {659 if (is_string($holidayDate = self::_getDateValue($holidayDate))) {660 return PHPExcel_Calculation_Functions::VALUE();661 }662 if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {663 if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {664 --$partWeekDays;665 $holidayCountedArray[] = $holidayDate;666 }667 }668 }669 if ($sDate > $eDate) {670 return 0 - ($wholeWeekDays + $partWeekDays);671 }672 return $wholeWeekDays + $partWeekDays;673 } // function NETWORKDAYS()674 /**675 * WORKDAY676 *677 * @param mixed Start date678 * @param mixed number of days for adjustment679 * @param array of mixed Optional Date Series680 * @return long Interval between the dates681 */682 public static function WORKDAY($startDate,$endDays) {683 // Retrieve the mandatory start date and days that are referenced in the function definition684 $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);685 $endDays = (int) PHPExcel_Calculation_Functions::flattenSingleValue($endDays);686 // Flush the mandatory start date and days that are referenced in the function definition, and get the optional days687 $dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());688 array_shift($dateArgs);689 array_shift($dateArgs);690 if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) {691 return PHPExcel_Calculation_Functions::VALUE();692 }693 $startDate = (float) floor($startDate);694 // If endDays is 0, we always return startDate695 if ($endDays == 0) { return $startDate; }696 $decrementing = ($endDays < 0) ? True : False;697 // Adjust the start date if it falls over a weekend698 $startDoW = self::DAYOFWEEK($startDate,3);699 if (self::DAYOFWEEK($startDate,3) >= 5) {700 $startDate += ($decrementing) ? -$startDoW + 4: 7 - $startDoW;701 ($decrementing) ? $endDays++ : $endDays--;702 }703 // Add endDays704 $endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5);705 // Adjust the calculated end date if it falls over a weekend706 $endDoW = self::DAYOFWEEK($endDate,3);707 if ($endDoW >= 5) {708 $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;709 }710 // Test any extra holiday parameters711 if (count($dateArgs) > 0) {712 $holidayCountedArray = $holidayDates = array();713 foreach ($dateArgs as $holidayDate) {714 if ((!is_null($holidayDate)) && (trim($holidayDate) > '')) {715 if (is_string($holidayDate = self::_getDateValue($holidayDate))) {716 return PHPExcel_Calculation_Functions::VALUE();717 }718 if (self::DAYOFWEEK($holidayDate,3) < 5) {719 $holidayDates[] = $holidayDate;720 }721 }722 }723 if ($decrementing) {724 rsort($holidayDates, SORT_NUMERIC);725 } else {726 sort($holidayDates, SORT_NUMERIC);727 }728 foreach ($holidayDates as $holidayDate) {729 if ($decrementing) {730 if (($holidayDate <= $startDate) && ($holidayDate >= $endDate)) {731 if (!in_array($holidayDate,$holidayCountedArray)) {732 --$endDate;733 $holidayCountedArray[] = $holidayDate;734 }735 }736 } else {737 if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {738 if (!in_array($holidayDate,$holidayCountedArray)) {739 ++$endDate;740 $holidayCountedArray[] = $holidayDate;741 }742 }743 }744 // Adjust the calculated end date if it falls over a weekend745 $endDoW = self::DAYOFWEEK($endDate,3);746 if ($endDoW >= 5) {747 $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;748 }749 }750 }751 switch (PHPExcel_Calculation_Functions::getReturnDateType()) {752 case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :753 return (float) $endDate;754 break;755 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :756 return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate);757 break;758 case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :759 return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);760 break;761 }762 } // function WORKDAY()763 /**764 * DAYOFMONTH765 *766 * @param long $dateValue Excel date serial value or a standard date string767 * @return int Day768 */769 public static function DAYOFMONTH($dateValue = 1) {770 $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);771 if (is_string($dateValue = self::_getDateValue($dateValue))) {772 return PHPExcel_Calculation_Functions::VALUE();773 } elseif ($dateValue == 0.0) {...

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1$ob = new value();2$ob->end();3$ob = new value();4$ob->end();5$ob = new value();6$ob->end();7$ob = new value();8$ob->end();9$ob = new value();10$ob->end();11$ob = new value();12$ob->end();13$ob = new value();14$ob->end();15$ob = new value();16$ob->end();17$ob = new value();18$ob->end();19$ob = new value();20$ob->end();21$ob = new value();22$ob->end();23$ob = new value();24$ob->end();25$ob = new value();26$ob->end();27$ob = new value();28$ob->end();29$ob = new value();30$ob->end();31$ob = new value();32$ob->end();33$ob = new value();34$ob->end();35$ob = new value();36$ob->end();

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1$var = new Value();2$var->end();3PHP: end() function4end(array);5$var = array(1,2,3,4,5);6end($var);7echo $var[4];8How to use the end() function in PHP?9How to use the end() function in PHP?

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1$obj = new value();2$obj->end();3$obj2 = new value();4$obj2->end();5$obj3 = new value();6$obj3->end();7$obj4 = new value();8$obj4->end();9$obj5 = new value();10$obj5->end();11$obj6 = new value();12$obj6->end();13$obj7 = new value();14$obj7->end();15$obj8 = new value();16$obj8->end();17$obj9 = new value();18$obj9->end();19$obj10 = new value();20$obj10->end();21$obj11 = new value();22$obj11->end();23$obj12 = new value();24$obj12->end();25$obj13 = new value();26$obj13->end();27$obj14 = new value();28$obj14->end();29$obj15 = new value();30$obj15->end();31$obj16 = new value();32$obj16->end();33$obj17 = new value();34$obj17->end();35$obj18 = new value();36$obj18->end();37$obj19 = new value();38$obj19->end();39$obj20 = new value();40$obj20->end();41$obj21 = new value();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger end code on LambdaTest Cloud Grid

Execute automation tests with end on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful