OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
344 stars 139 forks source link

Software Installed date #380

Closed haidars closed 2 years ago

haidars commented 2 years ago

Server informations

image

Problem's description

For some CI, the software installdate is set to the currentdate instead of the date present in the XML.

here is an example of data from the XML generated by the unix agent 2.8.0

<SOFTWARES>
<ARCH>x86_64</ARCH>
<COMMENTS>LZMA compression utilities</COMMENTS>
<FILESIZE>432832</FILESIZE>
<FROM>rpm</FROM>
<INSTALLDATE>01/09/2020</INSTALLDATE>
<NAME>xz</NAME>
<PUBLISHER>CentOS</PUBLISHER>
<SYSTEM_CATEGORY>Unspecified</SYSTEM_CATEGORY>
<VERSION>5.2.4-3.el8</VERSION>
</SOFTWARES>

here is the date in OCS server

image

i found that in software.pm , there it validation on the $software->{INSTALLDATE} and it expect it data to be in the format YYYY-MM-DD hh:mm:ss if it not it will reset the variable $software->{INSTALLDATE} to localtime $software->{INSTALLDATE} = strftime "%Y/%m/%d", localtime;

but currently some agent generate the date as DD/MM/YYYY and on windows, some application does output the date in correct format but does not has timestamp.

can we update the validation to include date in the format DD/MM/YYYY and convert it to YYYY/MM/DD

        # Check if Install date is in the format DD/MM/YYYY and reformat in YYYY/MM/DD
        if(!defined $software->{INSTALLDATE} || $software->{INSTALLDATE} =~ /^\d{2}\/\d{2}\/\d{4}/) {
            $software->{INSTALLDATE} =~ s /(^\d{2})\/(\d{2})\/(\d{4}$)/$3\/$2\/$1/; 
        }
charleneauger commented 2 years ago

Hi @haidars ,

The problem with this change is that we have no way of knowing if the date format is DD/MM/YYYY or MM/DD/YYYY. Hence the fact that we cannot include this modification.

Best regards, Charlene