Rename DAYOFWEEK into WEEKDAY for consistency

This commit is contained in:
Adrien Crivelli 2016-10-02 09:35:50 +09:00
parent 4c41a6992a
commit 382d15a5c3
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
8 changed files with 18 additions and 18 deletions

View File

@ -38,7 +38,7 @@ CATEGORY_DATE_AND_TIME
TIME PHPExcel_Calculation_DateTime::TIME TIME PHPExcel_Calculation_DateTime::TIME
TIMEVALUE PHPExcel_Calculation_DateTime::TIMEVALUE TIMEVALUE PHPExcel_Calculation_DateTime::TIMEVALUE
TODAY PHPExcel_Calculation_DateTime::DATENOW TODAY PHPExcel_Calculation_DateTime::DATENOW
WEEKDAY PHPExcel_Calculation_DateTime::DAYOFWEEK WEEKDAY PHPExcel_Calculation_DateTime::WEEKDAY
WEEKNUM PHPExcel_Calculation_DateTime::WEEKNUM WEEKNUM PHPExcel_Calculation_DateTime::WEEKNUM
WORKDAY PHPExcel_Calculation_DateTime::WORKDAY WORKDAY PHPExcel_Calculation_DateTime::WORKDAY
YEAR PHPExcel_Calculation_DateTime::YEAR YEAR PHPExcel_Calculation_DateTime::YEAR

View File

@ -364,7 +364,7 @@ VDB CATEGORY_FINANCIAL *** Not yet Implemented
VERSION CATEGORY_INFORMATION PHPExcel_Calculation_Functions::VERSION VERSION CATEGORY_INFORMATION PHPExcel_Calculation_Functions::VERSION
VLOOKUP CATEGORY_LOOKUP_AND_REFERENCE PHPExcel_Calculation_LookupRef::VLOOKUP 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 WEEKNUM CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WEEKNUM
WEIBULL CATEGORY_STATISTICAL PHPExcel_Calculation_Statistical::WEIBULL WEIBULL CATEGORY_STATISTICAL PHPExcel_Calculation_Statistical::WEIBULL
WORKDAY CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WORKDAY WORKDAY CATEGORY_DATE_AND_TIME PHPExcel_Calculation_DateTime::WORKDAY

View File

@ -925,7 +925,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
```php ```php
$retVal = call_user_func_array( $retVal = call_user_func_array(
array('PHPExcel_Calculation_Functions', 'DAYOFWEEK'), array('PHPExcel_Calculation_Functions', 'WEEKDAY'),
array('14-July-2008') array('14-July-2008')
); );
// $retVal = 7 // $retVal = 7
@ -933,7 +933,7 @@ $retVal = call_user_func_array(
##### Notes ##### 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 #### WEEKNUM

View File

@ -47,7 +47,7 @@
TIME | PHPExcel_Calculation_DateTime::TIME TIME | PHPExcel_Calculation_DateTime::TIME
TIMEVALUE | PHPExcel_Calculation_DateTime::TIMEVALUE TIMEVALUE | PHPExcel_Calculation_DateTime::TIMEVALUE
TODAY | PHPExcel_Calculation_DateTime::DATENOW TODAY | PHPExcel_Calculation_DateTime::DATENOW
WEEKDAY | PHPExcel_Calculation_DateTime::DAYOFWEEK WEEKDAY | PHPExcel_Calculation_DateTime::WEEKDAY
WEEKNUM | PHPExcel_Calculation_DateTime::WEEKNUM WEEKNUM | PHPExcel_Calculation_DateTime::WEEKNUM
WORKDAY | PHPExcel_Calculation_DateTime::WORKDAY WORKDAY | PHPExcel_Calculation_DateTime::WORKDAY
YEAR | PHPExcel_Calculation_DateTime::YEAR YEAR | PHPExcel_Calculation_DateTime::YEAR

View File

@ -456,7 +456,7 @@
Excel Function | Category | PHPExcel Function 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 WEEKNUM | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WEEKNUM
WEIBULL | CATEGORY_STATISTICAL | PHPExcel_Calculation_Statistical::WEIBULL WEIBULL | CATEGORY_STATISTICAL | PHPExcel_Calculation_Statistical::WEIBULL
WORKDAY | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WORKDAY WORKDAY | CATEGORY_DATE_AND_TIME | PHPExcel_Calculation_DateTime::WORKDAY

View File

@ -1960,7 +1960,7 @@ class Calculation
], ],
'WEEKDAY' => [ 'WEEKDAY' => [
'category' => Calculation\Categories::CATEGORY_DATE_AND_TIME, 'category' => Calculation\Categories::CATEGORY_DATE_AND_TIME,
'functionCall' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime::DAYOFWEEK', 'functionCall' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime::WEEKDAY',
'argumentCount' => '1,2', 'argumentCount' => '1,2',
], ],
'WEEKNUM' => [ 'WEEKNUM' => [

View File

@ -946,11 +946,11 @@ class DateTime
} }
// Execute function // Execute function
$startDoW = 6 - self::DAYOFWEEK($startDate, 2); $startDoW = 6 - self::WEEKDAY($startDate, 2);
if ($startDoW < 0) { if ($startDoW < 0) {
$startDoW = 0; $startDoW = 0;
} }
$endDoW = self::DAYOFWEEK($endDate, 2); $endDoW = self::WEEKDAY($endDate, 2);
if ($endDoW >= 6) { if ($endDoW >= 6) {
$endDoW = 0; $endDoW = 0;
} }
@ -968,7 +968,7 @@ class DateTime
return Functions::VALUE(); return Functions::VALUE();
} }
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) { 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; --$partWeekDays;
$holidayCountedArray[] = $holidayDate; $holidayCountedArray[] = $holidayDate;
} }
@ -1026,8 +1026,8 @@ class DateTime
// Adjust the start date if it falls over a weekend // Adjust the start date if it falls over a weekend
$startDoW = self::DAYOFWEEK($startDate, 3); $startDoW = self::WEEKDAY($startDate, 3);
if (self::DAYOFWEEK($startDate, 3) >= 5) { if (self::WEEKDAY($startDate, 3) >= 5) {
$startDate += ($decrementing) ? -$startDoW + 4 : 7 - $startDoW; $startDate += ($decrementing) ? -$startDoW + 4 : 7 - $startDoW;
($decrementing) ? $endDays++ : $endDays--; ($decrementing) ? $endDays++ : $endDays--;
} }
@ -1036,7 +1036,7 @@ class DateTime
$endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5); $endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5);
// Adjust the calculated end date if it falls over a weekend // Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate, 3); $endDoW = self::WEEKDAY($endDate, 3);
if ($endDoW >= 5) { if ($endDoW >= 5) {
$endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW;
} }
@ -1049,7 +1049,7 @@ class DateTime
if (is_string($holidayDate = self::getDateValue($holidayDate))) { if (is_string($holidayDate = self::getDateValue($holidayDate))) {
return Functions::VALUE(); return Functions::VALUE();
} }
if (self::DAYOFWEEK($holidayDate, 3) < 5) { if (self::WEEKDAY($holidayDate, 3) < 5) {
$holidayDates[] = $holidayDate; $holidayDates[] = $holidayDate;
} }
} }
@ -1076,7 +1076,7 @@ class DateTime
} }
} }
// Adjust the calculated end date if it falls over a weekend // Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate, 3); $endDoW = self::WEEKDAY($endDate, 3);
if ($endDoW >= 5) { if ($endDoW >= 5) {
$endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; $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 * 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). * ranging from 0 to 7 (dependent on the requested style).
@ -1143,7 +1143,7 @@ class DateTime
* 3 Numbers 0 (Monday) through 6 (Sunday). * 3 Numbers 0 (Monday) through 6 (Sunday).
* @return int Day of the week value * @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); $dateValue = Functions::flattenSingleValue($dateValue);
$style = Functions::flattenSingleValue($style); $style = Functions::flattenSingleValue($style);

View File

@ -161,7 +161,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase
{ {
$args = func_get_args(); $args = func_get_args();
$expectedResult = array_pop($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); $this->assertEquals($expectedResult, $result, null, 1E-8);
} }