From 382d15a5c397218dd7511a93f877100cf1f37c6e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 2 Oct 2016 09:35:50 +0900 Subject: [PATCH] Rename DAYOFWEEK into WEEKDAY for consistency --- Documentation/FunctionListByCategory.txt | 2 +- Documentation/FunctionListByName.txt | 2 +- .../03-03-Date-and-Time-Functions.md | 4 ++-- .../Functions/FunctionListByCategory.md | 2 +- .../markdown/Functions/FunctionListByName.md | 2 +- src/PhpSpreadsheet/Calculation.php | 2 +- src/PhpSpreadsheet/Calculation/DateTime.php | 20 +++++++++---------- .../Calculation/DateTimeTest.php | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Documentation/FunctionListByCategory.txt b/Documentation/FunctionListByCategory.txt index 7ac726d3..824346b3 100644 --- a/Documentation/FunctionListByCategory.txt +++ b/Documentation/FunctionListByCategory.txt @@ -38,7 +38,7 @@ CATEGORY_DATE_AND_TIME TIME PHPExcel_Calculation_DateTime::TIME TIMEVALUE PHPExcel_Calculation_DateTime::TIMEVALUE TODAY PHPExcel_Calculation_DateTime::DATENOW - WEEKDAY PHPExcel_Calculation_DateTime::DAYOFWEEK + WEEKDAY PHPExcel_Calculation_DateTime::WEEKDAY WEEKNUM PHPExcel_Calculation_DateTime::WEEKNUM WORKDAY PHPExcel_Calculation_DateTime::WORKDAY YEAR PHPExcel_Calculation_DateTime::YEAR diff --git a/Documentation/FunctionListByName.txt b/Documentation/FunctionListByName.txt index 2305f213..4c7ad87a 100644 --- a/Documentation/FunctionListByName.txt +++ b/Documentation/FunctionListByName.txt @@ -364,7 +364,7 @@ VDB CATEGORY_FINANCIAL *** Not yet Implemented VERSION CATEGORY_INFORMATION PHPExcel_Calculation_Functions::VERSION VLOOKUP CATEGORY_LOOKUP_AND_REFERENCE PHPExcel_Calculation_LookupRef::VLOOKUP -WEEKDAY CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::DAYOFWEEK +WEEKDAY CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WEEKDAY WEEKNUM CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WEEKNUM WEIBULL CATEGORY_STATISTICAL PHPExcel_Calculation_Statistical::WEIBULL WORKDAY CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WORKDAY diff --git a/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md b/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md index d0cc5681..db7bc0e3 100644 --- a/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md +++ b/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md @@ -925,7 +925,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); ```php $retVal = call_user_func_array( - array('PHPExcel_Calculation_Functions', 'DAYOFWEEK'), + array('PHPExcel_Calculation_Functions', 'WEEKDAY'), array('14-July-2008') ); // $retVal = 7 @@ -933,7 +933,7 @@ $retVal = call_user_func_array( ##### Notes -Note that the PHPExcel function is PHPExcel_Calculation_Functions::DAYOFWEEK() when the method is called statically. +Note that the PHPExcel function is PHPExcel_Calculation_Functions::WEEKDAY() when the method is called statically. #### WEEKNUM diff --git a/Documentation/markdown/Functions/FunctionListByCategory.md b/Documentation/markdown/Functions/FunctionListByCategory.md index 62c46f64..d1d99d39 100644 --- a/Documentation/markdown/Functions/FunctionListByCategory.md +++ b/Documentation/markdown/Functions/FunctionListByCategory.md @@ -47,7 +47,7 @@ TIME | PHPExcel_Calculation_DateTime::TIME TIMEVALUE | PHPExcel_Calculation_DateTime::TIMEVALUE TODAY | PHPExcel_Calculation_DateTime::DATENOW - WEEKDAY | PHPExcel_Calculation_DateTime::DAYOFWEEK + WEEKDAY | PHPExcel_Calculation_DateTime::WEEKDAY WEEKNUM | PHPExcel_Calculation_DateTime::WEEKNUM WORKDAY | PHPExcel_Calculation_DateTime::WORKDAY YEAR | PHPExcel_Calculation_DateTime::YEAR diff --git a/Documentation/markdown/Functions/FunctionListByName.md b/Documentation/markdown/Functions/FunctionListByName.md index addae289..5a61aa7d 100644 --- a/Documentation/markdown/Functions/FunctionListByName.md +++ b/Documentation/markdown/Functions/FunctionListByName.md @@ -456,7 +456,7 @@ Excel Function | Category | PHPExcel Function --------------------|--------------------------------|------------------------------------------- - WEEKDAY | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::DAYOFWEEK + WEEKDAY | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WEEKDAY WEEKNUM | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WEEKNUM WEIBULL | CATEGORY_STATISTICAL | PHPExcel_Calculation_Statistical::WEIBULL WORKDAY | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WORKDAY diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index bd643dea..fbf90ca7 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -1960,7 +1960,7 @@ class Calculation ], 'WEEKDAY' => [ 'category' => Calculation\Categories::CATEGORY_DATE_AND_TIME, - 'functionCall' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime::DAYOFWEEK', + 'functionCall' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime::WEEKDAY', 'argumentCount' => '1,2', ], 'WEEKNUM' => [ diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 548e1f1d..a2043cb0 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -946,11 +946,11 @@ class DateTime } // Execute function - $startDoW = 6 - self::DAYOFWEEK($startDate, 2); + $startDoW = 6 - self::WEEKDAY($startDate, 2); if ($startDoW < 0) { $startDoW = 0; } - $endDoW = self::DAYOFWEEK($endDate, 2); + $endDoW = self::WEEKDAY($endDate, 2); if ($endDoW >= 6) { $endDoW = 0; } @@ -968,7 +968,7 @@ class DateTime return Functions::VALUE(); } if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) { - if ((self::DAYOFWEEK($holidayDate, 2) < 6) && (!in_array($holidayDate, $holidayCountedArray))) { + if ((self::WEEKDAY($holidayDate, 2) < 6) && (!in_array($holidayDate, $holidayCountedArray))) { --$partWeekDays; $holidayCountedArray[] = $holidayDate; } @@ -1026,8 +1026,8 @@ class DateTime // Adjust the start date if it falls over a weekend - $startDoW = self::DAYOFWEEK($startDate, 3); - if (self::DAYOFWEEK($startDate, 3) >= 5) { + $startDoW = self::WEEKDAY($startDate, 3); + if (self::WEEKDAY($startDate, 3) >= 5) { $startDate += ($decrementing) ? -$startDoW + 4 : 7 - $startDoW; ($decrementing) ? $endDays++ : $endDays--; } @@ -1036,7 +1036,7 @@ class DateTime $endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5); // Adjust the calculated end date if it falls over a weekend - $endDoW = self::DAYOFWEEK($endDate, 3); + $endDoW = self::WEEKDAY($endDate, 3); if ($endDoW >= 5) { $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; } @@ -1049,7 +1049,7 @@ class DateTime if (is_string($holidayDate = self::getDateValue($holidayDate))) { return Functions::VALUE(); } - if (self::DAYOFWEEK($holidayDate, 3) < 5) { + if (self::WEEKDAY($holidayDate, 3) < 5) { $holidayDates[] = $holidayDate; } } @@ -1076,7 +1076,7 @@ class DateTime } } // Adjust the calculated end date if it falls over a weekend - $endDoW = self::DAYOFWEEK($endDate, 3); + $endDoW = self::WEEKDAY($endDate, 3); if ($endDoW >= 5) { $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; } @@ -1127,7 +1127,7 @@ class DateTime } /** - * DAYOFWEEK + * WEEKDAY * * 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). @@ -1143,7 +1143,7 @@ class DateTime * 3 Numbers 0 (Monday) through 6 (Sunday). * @return int Day of the week value */ - public static function DAYOFWEEK($dateValue = 1, $style = 1) + public static function WEEKDAY($dateValue = 1, $style = 1) { $dateValue = Functions::flattenSingleValue($dateValue); $style = Functions::flattenSingleValue($style); diff --git a/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php b/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php index 0893b038..1046281c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php @@ -161,7 +161,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array([DateTime::class, 'DAYOFWEEK'], $args); + $result = call_user_func_array([DateTime::class, 'WEEKDAY'], $args); $this->assertEquals($expectedResult, $result, null, 1E-8); }