# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Calculation/Financial/Helpers.php

TablePress – Tables in WordPress made easy, version 3.4. 62 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/Financial/Helpers.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Calculation/Financial/Helpers.php
- Modified: 2025-04-29T05:06:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/Financial/Helpers.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial;

use DateTimeInterface;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;

class Helpers
{
	/**
	 * daysPerYear.
	 *
	 * Returns the number of days in a specified year, as defined by the "basis" value
	 *
	 * @param mixed $year The year against which we're testing, expect int|string
	 * @param int|string $basis The type of day count:
	 *                              0 or omitted US (NASD)   360
	 *                              1                        Actual (365 or 366 in a leap year)
	 *                              2                        360
	 *                              3                        365
	 *                              4                        European 360
	 *
	 * @return int|string Result, or a string containing an error
	 */
	public static function daysPerYear($year, $basis = 0)
	{
		if (!is_int($year) && !is_string($year)) {
			return ExcelError::VALUE();
		}
		if (!is_numeric($basis)) {
			return ExcelError::NAN();
		}

		switch ($basis) {
			case FinancialConstants::BASIS_DAYS_PER_YEAR_NASD:
			case FinancialConstants::BASIS_DAYS_PER_YEAR_360:
			case FinancialConstants::BASIS_DAYS_PER_YEAR_360_EUROPEAN:
				return 360;
			case FinancialConstants::BASIS_DAYS_PER_YEAR_365:
				return 365;
			case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL:
				return (DateTimeExcel\Helpers::isLeapYear($year)) ? 366 : 365;
		}

		return ExcelError::NAN();
	}

	/**
	 * isLastDayOfMonth.
	 *
	 * Returns a boolean TRUE/FALSE indicating if this date is the last date of the month
	 *
	 * @param DateTimeInterface $date The date for testing
	 */
	public static function isLastDayOfMonth(DateTimeInterface $date): bool
	{
		return $date->format('d') === $date->format('t');
	}
}

```
