public static function PHPExcel_Calculation_DateTime::DAYOFWEEK in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php \PHPExcel_Calculation_DateTime::DAYOFWEEK()
* DAYOFWEEK * * Returns the day of the week for a specified date. The day is given as an integer * ranging from 0 to 7 (dependent on the requested style). * * Excel Function: * WEEKDAY(dateValue[,style]) * *
Parameters
mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),: * PHP DateTime object, or a standard date string * @param int $style A number that determines the type of return value * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). * 2 Numbers 1 (Monday) through 7 (Sunday). * 3 Numbers 0 (Monday) through 6 (Sunday). * @return int Day of the week value
2 calls to PHPExcel_Calculation_DateTime::DAYOFWEEK()
- PHPExcel_Calculation_DateTime::NETWORKDAYS in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ DateTime.php - * NETWORKDAYS * * Returns the number of whole working days between start_date and end_date. Working days * exclude weekends and any dates identified in holidays. * Use NETWORKDAYS to calculate employee benefits that accrue based on the number…
- PHPExcel_Calculation_DateTime::WORKDAY in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ DateTime.php - * WORKDAY * * Returns the date that is the indicated number of working days before or after a date (the * starting date). Working days exclude weekends and any dates identified as holidays. * Use WORKDAY to exclude weekends or holidays when…
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ DateTime.php, line 1108
Class
- PHPExcel_Calculation_DateTime
- PHPExcel_Calculation_DateTime
Code
public static function DAYOFWEEK($dateValue = 1, $style = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
$style = PHPExcel_Calculation_Functions::flattenSingleValue($style);
if (!is_numeric($style)) {
return PHPExcel_Calculation_Functions::VALUE();
}
elseif ($style < 1 || $style > 3) {
return PHPExcel_Calculation_Functions::NaN();
}
$style = floor($style);
if ($dateValue === null) {
$dateValue = 1;
}
elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
}
elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$DoW = $PHPDateObject
->format('w');
$firstDay = 1;
switch ($style) {
case 1:
++$DoW;
break;
case 2:
if ($DoW == 0) {
$DoW = 7;
}
break;
case 3:
if ($DoW == 0) {
$DoW = 7;
}
$firstDay = 0;
--$DoW;
break;
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL) {
// Test for Excel's 1900 leap year, and introduce the error as required
if ($PHPDateObject
->format('Y') == 1900 && $PHPDateObject
->format('n') <= 2) {
--$DoW;
if ($DoW < $firstDay) {
$DoW += 7;
}
}
}
return (int) $DoW;
}