@@ 1281-1298 (lines=18) @@ | ||
1278 | * PHP DateTime object, or a standard date string |
|
1279 | * @return int Month of the year |
|
1280 | */ |
|
1281 | public static function MONTHOFYEAR($dateValue = 1) |
|
1282 | { |
|
1283 | $dateValue = Functions::flattenSingleValue($dateValue); |
|
1284 | ||
1285 | if (empty($dateValue)) { |
|
1286 | $dateValue = 1; |
|
1287 | } |
|
1288 | if (is_string($dateValue = self::getDateValue($dateValue))) { |
|
1289 | return Functions::VALUE(); |
|
1290 | } elseif ($dateValue < 0.0) { |
|
1291 | return Functions::NAN(); |
|
1292 | } |
|
1293 | ||
1294 | // Execute function |
|
1295 | $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); |
|
1296 | ||
1297 | return (int) $PHPDateObject->format('n'); |
|
1298 | } |
|
1299 | ||
1300 | /** |
|
1301 | * YEAR |
|
@@ 1313-1329 (lines=17) @@ | ||
1310 | * PHP DateTime object, or a standard date string |
|
1311 | * @return int Year |
|
1312 | */ |
|
1313 | public static function YEAR($dateValue = 1) |
|
1314 | { |
|
1315 | $dateValue = Functions::flattenSingleValue($dateValue); |
|
1316 | ||
1317 | if ($dateValue === null) { |
|
1318 | $dateValue = 1; |
|
1319 | } elseif (is_string($dateValue = self::getDateValue($dateValue))) { |
|
1320 | return Functions::VALUE(); |
|
1321 | } elseif ($dateValue < 0.0) { |
|
1322 | return Functions::NAN(); |
|
1323 | } |
|
1324 | ||
1325 | // Execute function |
|
1326 | $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); |
|
1327 | ||
1328 | return (int) $PHPDateObject->format('Y'); |
|
1329 | } |
|
1330 | ||
1331 | /** |
|
1332 | * HOUROFDAY |