39 $baseYear = SharedDateHelper::getExcelCalendar();
42 $dateValue = preg_replace(
'/(\d)(st|nd|rd|th)([ -\/])/Ui',
'$1$3', $dateValue) ??
'';
44 $dateValue = str_replace([
'/',
'.',
'-',
' '],
' ', $dateValue);
47 $t1 = explode(
' ', $dateValue);
49 foreach ($t1 as &
$t) {
50 if ((is_numeric($t)) && ($t > 31)) {
60 if (count($t1) === 1) {
62 return ((strpos((
string) $t,
':') ===
false)) ? Functions::Value() : 0.0;
66 $dateValue = self::t1ToString($t1, $dti, $yearFound);
68 $PHPDateArray = self::setUpArray($dateValue, $dti);
70 return self::finalResults($PHPDateArray, $dti, $baseYear);
75 if (count($t1) == 2) {
78 array_unshift($t1, 1);
80 if (is_numeric($t1[1]) && $t1[1] > 29) {
82 array_unshift($t1, 1);
84 $t1[] = $dti->format(
'Y');
88 $dateValue = implode(
' ', $t1);
100 $PHPDateArray = date_parse($dateValue);
101 if (($PHPDateArray ===
false) || ($PHPDateArray[
'error_count'] > 0)) {
105 $testVal1 = strtok($dateValue,
'- ');
106 $testVal2 = strtok(
'- ');
107 $testVal3 = strtok(
'- ') ?: $dti->format(
'Y');
109 $PHPDateArray = date_parse($testVal1 .
'-' . $testVal2 .
'-' . $testVal3);
110 if (($PHPDateArray ===
false) || ($PHPDateArray[
'error_count'] > 0)) {
111 $PHPDateArray = date_parse($testVal2 .
'-' . $testVal1 .
'-' . $testVal3);
115 return $PHPDateArray;
128 $retValue = Functions::Value();
129 if (is_array($PHPDateArray) && $PHPDateArray[
'error_count'] == 0) {
132 if ($PHPDateArray[
'year'] < $baseYear) {
137 $PHPDateArray[
'hour'] = 0;
138 $PHPDateArray[
'minute'] = 0;
139 $PHPDateArray[
'second'] = 0;
140 $month = (int) $PHPDateArray[
'month'];
141 $day = (int) $PHPDateArray[
'day'];
142 $year = (int) $PHPDateArray[
'year'];
143 if (!checkdate($month, $day, $year)) {
static replaceIfEmpty(&$value, $altValue)
Help reduce perceived complexity of some tests.
static finalResults($PHPDateArray, DateTimeImmutable $dti, int $baseYear)
Final results.
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 t1ToString(array $t1, DateTimeImmutable $dti, bool $yearFound)
static fromString($dateValue)
DATEVALUE.
static setUpArray(string $dateValue, DateTimeImmutable $dti)
Parse date.
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.