Topic: A non-numeric value encountered in \includes\date_functions.inc

Hi,

I am getting numerous non-numeric value errors in date_functions.inc line 399 (like below).

A non-numeric value encountered in file: D:\Users\shipl\htdocs\fa24\includes\date_functions.inc at line 399
D:\Users\shipl\htdocs\fa24\includes\date_functions.inc:531:     date2sql('2019/Mar/5')
D:\Users\shipl\htdocs\fa24\includes\references.inc:125:     explode_date_to_dmy('2019/Mar/5')
D:\Users\shipl\htdocs\fa24\includes\references.inc:252:     (references Object)->_parse_next('1','',(Array[3]))
D:\Users\shipl\htdocs\fa24\gl\gl_bank.php:203:     (references Object)->get_next('1','','')
D:\Users\shipl\htdocs\fa24\gl\gl_bank.php:35:     create_cart('1','0')

This issue seems to be due to the handling of non-numeric months (like in date formats 3,4,5). I am using date format 5 (YYYYMmmDD - 2019/Mar/5) in \includes\date_functions.inc


    if ($year+$day+$month) {
        if ($how > 2)
        {
            global $tmonths;
            $month = array_search($month, $tmonths);
        }

I believe that this should be

    if ($how > 2)
    {
        global $tmonths;
        $month = array_search($month, $tmonths);
    }

    if ($year+$day+$month) {

The patch file is

399,404d398
<     if ($how > 2)
<     {
<         global $tmonths;
<         $month = array_search($month, $tmonths);
<     }
<
406c400,405
<          //to modify assumption in 2030
---
>         if ($how > 2)
>         {
>             global $tmonths;
>             $month = array_search($month, $tmonths);
>         }
>         //to modify assumption in 2030

Hope this helps

Re: A non-numeric value encountered in \includes\date_functions.inc

@joe: should this be included? Never seen such a date format in practical use though!

Re: A non-numeric value encountered in \includes\date_functions.inc

Which PHP-version is used?

Joe

Re: A non-numeric value encountered in \includes\date_functions.inc

@PaulShipley

This was a PHP 7.X error. Thanks for finding this and showing the resolution.

Committed to repo. The fixed file can be downloaded here.

Joe

Re: A non-numeric value encountered in \includes\date_functions.inc

Thanks for the quick fix Joe.

FYI. This was with PHP 7.2.15 on Windows 10 with XAMPP 7.2.15 (2019/03/01)

@apmuthu

Mmm formats (like format 5 - YYYYMmmDD) are even clear to our American friends, whereas 03/04 could be 4th of March or 3rd of April. :-)