Categories > OpenTBS with XLSX >

OpenTBS tbs:date modification propose

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Alexey
Date: 2016-04-05
Time: 10:14

OpenTBS tbs:date modification propose

Hi Skrol

I want propose make saome fix in code of OpenTBS plugin.

It is related to tbs:date operation in block :
        case 'tbs:date':
        case 'tbs:time':
        case 'xlsxDate':
            if (is_string($Value)) {
                $t = strtotime($Value); // We look if it's a date
            } else {
                $t = $Value;
            if (($t===-1) or ($t===false)) { // Date not recognized
                $Value = '';
            } elseif ($t===943916400) { // Date to zero
                $Value = '';
            } else { // It's a date
                $Value = ($t/86400.00)+25569; // unix: 1 means 01/01/1970, xls: 1 means 01/01/1900

Propose is to add here
if (($t===-1) or ($t===false)) { // Date not recognized

check for null :
if (($t===-1) or ($t===false) or ($t===null)) { // Date not recognized

For example, when data source is DB, and Date field has value = Null in DB, we will have date 1970-01-01 instead of empty cell in XLSX after merging.
By: Skrol29
Date: 2016-05-11
Time: 01:16

Re: OpenTBS tbs:date modification propose

Hi Alexey,

Thank for your submitting.
This will be taken for the next version.