Issue Bug Closed

#21838Date field on TCA can't accept 1-1-1970 as

Équipe Tactic 12/10/09, 22:12 updated 01/09/15, 04:44

Description

The problem arises when a backend field is setted as an input with an date evaluation ni the TCA (like this :
‘dateacquisition’ => array (
‘exclude’ => 0,
‘label’ => ‘LLL:EXT:tactic_repoeuvres/locallang_db.xml:tx_tacticrepoeuvres_Oeuvres.dateacquisition’,
‘config’ => array (
‘type’ => ‘input’,
‘size’ => ‘8’,
‘max’ => ‘20’,
‘eval’ => ‘date’,
‘checkbox’ => ‘0’,
‘default’ => ’0’
)
),
)
When you enter 1-1-1970 as a date, the javascript evaluation erases the field.

Tried on Firefox 3.5 and IE 8.

To fix the problem, I added the following line :
if (this.lastDate==0) {this.lastDate++;} // Adds one second if 1-1-1970 is entered, so the variable won’t be evaluated as null
in the file :
t3lib\jsfunc.evalfield.js
after line 831

So that the zone becomes :
this.lastDate+=add*24*60*60;
if (this.lastDate==0) {this.lastDate++;} // Adds one second if 1-1-1970 is entered, so the variable won’t be evaluated as null
return this.lastDate;

That makes sure a 1-1-1970 date would get a minimum of 1 second as a timestamp and won’t be evaluated to null.

I am open to any other way to correct this bug.

(issue imported from #M13005)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.