21 return (($year % 4) === 0) && (($year % 100) !== 0) || (($year % 400) === 0);
31 public static function getDateValue($dateValue,
bool $allowBool =
true): float
33 if (is_object($dateValue)) {
34 $retval = SharedDateHelper::PHPToExcel($dateValue);
35 if (is_bool($retval)) {
42 self::nullFalseTrueToNumber($dateValue, $allowBool);
43 if (!is_numeric($dateValue)) {
48 if (!is_numeric($dateValue)) {
56 return (
float) $dateValue;
84 $PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
85 $oMonth = (int) $PHPDateObject->format(
'm');
86 $oYear = (int) $PHPDateObject->format(
'Y');
88 $adjustmentMonthsString = (string) $adjustmentMonths;
89 if ($adjustmentMonths > 0) {
90 $adjustmentMonthsString =
'+' . $adjustmentMonths;
92 if ($adjustmentMonths != 0) {
93 $PHPDateObject->modify($adjustmentMonthsString .
' months');
95 $nMonth = (int) $PHPDateObject->format(
'm');
96 $nYear = (int) $PHPDateObject->format(
'Y');
98 $monthDiff = ($nMonth - $oMonth) + (($nYear - $oYear) * 12);
99 if ($monthDiff != $adjustmentMonths) {
100 $adjustDays = (int) $PHPDateObject->format(
'd');
101 $adjustDaysString =
'-' . $adjustDays .
' days';
102 $PHPDateObject->modify($adjustDaysString);
105 return $PHPDateObject;
116 $value = $value ?: $altValue;
122 public static function adjustYear(
string $testVal1,
string $testVal2,
string &$testVal3): void
124 if (!is_numeric($testVal1) || $testVal1 < 31) {
125 if (!is_numeric($testVal2) || $testVal2 < 12) {
126 if (is_numeric($testVal3) && $testVal3 < 12) {
144 .
'-' . $dateArray[
'month']
145 .
'-' . $dateArray[
'day']
146 .
' ' . $dateArray[
'hour']
147 .
':' . $dateArray[
'minute']
148 .
':' . $dateArray[
'second']
152 SharedDateHelper::formattedPHPToExcel(
157 $dateArray[
'minute'],
161 return $noFrac ? floor($excelDateValue) : (float) $excelDateValue;
165 return (
int) SharedDateHelper::excelToTimestamp($excelDateValue);
177 return $excelDateValue;
180 return (
int) SharedDateHelper::excelToTimestamp($excelDateValue);
184 return SharedDateHelper::excelToDateTimeObject($excelDateValue);
196 return $PHPDateObject;
199 return (
float) SharedDateHelper::PHPToExcel($PHPDateObject);
202 $stamp = SharedDateHelper::PHPToExcel($PHPDateObject);
203 $stamp = is_bool($stamp) ? ((int) $stamp) : $stamp;
205 return (
int) SharedDateHelper::excelToTimestamp($stamp);
213 if (SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_MAC_1904) {
228 $nullVal = self::baseDate();
229 if ($number === null) {
231 } elseif ($allowBool && is_bool($number)) {
232 $number = $nullVal + (int) $number;
246 if ($number === null) {
249 if (is_int($number)) {
252 if (is_numeric($number)) {
253 return (
float) $number;
268 if (!is_numeric($number)) {
272 return (
float) $number;
280 $isoDate = $PHPDateObject->format(
'c');
281 if ($isoDate <
'1900-03-01') {
282 $PHPDateObject->modify($mod);
static replaceIfEmpty(&$value, $altValue)
Help reduce perceived complexity of some tests.
static getReturnDateType()
Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object).
static getTimeValue($timeValue)
getTimeValue.
static nullFalseTrueToNumber(&$number, bool $allowBool=true)
Many functions accept null/false/true argument treated as 0/0/1.
static setReturnDateType($returnDateType)
Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric o...
const RETURNDATE_UNIX_TIMESTAMP
static returnIn3FormatsFloat(float $excelDateValue)
Return result in one of three formats.
static adjustYear(string $testVal1, string $testVal2, string &$testVal3)
Adjust year in ambiguous situations.
static fromString($dateValue)
DATEVALUE.
static returnIn3FormatsObject(DateTime $PHPDateObject)
Return result in one of three formats.
static validateNotNegative($number)
Many functions accept null/false/true argument treated as 0/0/1.
const COMPATIBILITY_OPENOFFICE
static adjustDateByMonths($dateValue=0, float $adjustmentMonths=0)
Adjust date by given months.
static isLeapYear($year)
Identify if a year is a leap year or not.
static getDateValue($dateValue, bool $allowBool=true)
getDateValue.
const RETURNDATE_PHP_DATETIME_OBJECT
static silly1900(DateTime $PHPDateObject, string $mod='-1 day')
static validateNumericNull($number)
Many functions accept null argument treated as 0.
static returnIn3FormatsArray(array $dateArray, bool $noFrac=false)
Return result in one of three formats.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static fromString($timeValue)
TIMEVALUE.
static getCompatibilityMode()
Return the current Compatibility Mode.