@@ 1270-1287 (lines=18) @@ | ||
1267 | * PHP DateTime object, or a standard date string |
|
1268 | * @return int Month of the year |
|
1269 | */ |
|
1270 | public static function MONTHOFYEAR($dateValue = 1) |
|
1271 | { |
|
1272 | $dateValue = Functions::flattenSingleValue($dateValue); |
|
1273 | ||
1274 | if (empty($dateValue)) { |
|
1275 | $dateValue = 1; |
|
1276 | } |
|
1277 | if (is_string($dateValue = self::getDateValue($dateValue))) { |
|
1278 | return Functions::VALUE(); |
|
1279 | } elseif ($dateValue < 0.0) { |
|
1280 | return Functions::NAN(); |
|
1281 | } |
|
1282 | ||
1283 | // Execute function |
|
1284 | $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); |
|
1285 | ||
1286 | return (int) $PHPDateObject->format('n'); |
|
1287 | } |
|
1288 | ||
1289 | /** |
|
1290 | * YEAR |
|
@@ 1302-1318 (lines=17) @@ | ||
1299 | * PHP DateTime object, or a standard date string |
|
1300 | * @return int Year |
|
1301 | */ |
|
1302 | public static function YEAR($dateValue = 1) |
|
1303 | { |
|
1304 | $dateValue = Functions::flattenSingleValue($dateValue); |
|
1305 | ||
1306 | if ($dateValue === null) { |
|
1307 | $dateValue = 1; |
|
1308 | } elseif (is_string($dateValue = self::getDateValue($dateValue))) { |
|
1309 | return Functions::VALUE(); |
|
1310 | } elseif ($dateValue < 0.0) { |
|
1311 | return Functions::NAN(); |
|
1312 | } |
|
1313 | ||
1314 | // Execute function |
|
1315 | $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); |
|
1316 | ||
1317 | return (int) $PHPDateObject->format('Y'); |
|
1318 | } |
|
1319 | ||
1320 | /** |
|
1321 | * HOUROFDAY |