Project

General

Profile

Actions

Bug #19083

closed

Date fields calculate wrong date using shortcut mode

Added by Steffen Kamper about 16 years ago. Updated almost 16 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
Start date:
2008-10-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

It's possible to enter something like
+5
in a date field. After lost focus it's calculated as now() + 5 days.

Result is different from that, quick test:

+1: add 3 days
+2: add 2 days
+3: add 6 days

a.s.o.

(issue imported from #M9676)


Files

9676.diff (1.9 KB) 9676.diff Administrator Admin, 2008-11-07 09:50

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #18977: Date/time field problem with timezone shifting when using the "+xx" and "d" syntaxesClosedErnesto Baschny2008-06-18

Actions
Related to TYPO3 Core - Bug #19752: Shortcut "d" doesn't work as expected on date/time fieldsClosedErnesto Baschny2008-12-29

Actions
Actions #1

Updated by Martin Holtz about 16 years ago

as far as i can remeber, that feature works nearly as expected.

There is only one Bug:

there must be an global variable which holds "now()"

and now() is updated everytime you add and value into that field.

test that:

enter +1 to date field
go to another field,
clear value of date field and enter +1

you will get an +2 :)
and so on.

the example above:
+1: add 3 days
+2: add 2 days
+3: add 6 days

would has been done in that order:
+2: add 2 days
+1: add 3 days
+3: add 6 days

ok?

sorry, but i did not find the javascript which is responsible:/

regards,
martin

Actions #2

Updated by Martin Holtz about 16 years ago

it belongs to

this.lastDate in function evalFunc_input(type,inVal)

in file /t3lib/jsfunc.evalfield.js

this.lastDate += add*24*60*60;

if you enter "+2"
this.lastDate += 2*24*60*60 will be calulated.
but this.lastDate will not set back to current time.

but i do not know (now?) whats the correct way to fix it

Actions #3

Updated by Martin Holtz about 16 years ago

for case "date":

case "+":
case "-":
if (values.valPol1) {
add = this.pol(values.valPol1,this.parseInt(values.values1));
}
this.lastDate = this.getTimestamp(today);
var theTime = new Date();
theTime.setTime((this.lastDate - theTime.getTimezoneOffset()*60)*1000);
this.lastDate = this.getTimestamp(today);
break;

seems to work

but i am not sure do understand the whole thing - with time and datetime..

so i cannot write an patch atm

Actions #4

Updated by Martin Holtz about 16 years ago

ok, i added an patch,

but i did not test it enough

Actions #5

Updated by Michael Stucki almost 16 years ago

Thanks for the patch, it works fine. I'll post this to the core team list now.

Actions #6

Updated by Michael Stucki almost 16 years ago

Btw. does anyone know since when this is broken? I remember it worked pretty fine once...

Actions #7

Updated by Michael Stucki almost 16 years ago

After looking through the code, I will not change it. The issue was introduced in revision 2752 by Ernesto Baschny. It seems like it has to do with the timezone stuff which he fixed, and since he knows the logic best, I would like him to look at this.

Actions #8

Updated by Michael Stucki almost 16 years ago

Ernesto, can you please have a look at the proposed fix?

Actions #9

Updated by Michael Stucki almost 16 years ago

Changing target version to 4.2.5 because this won't be ready for 4.2.4.

Actions #10

Updated by Ernesto Baschny almost 16 years ago

As far as I can see, the described behaviour is not a bug, as it has always been like that (since 3.8.1, I just tested it).

The fix proposed by Martin would change the behaviour of +XX, and stuff like this won't work anymore: "2008-12-29 +2", which correctly results in "2008-12-31".

The only bugs I found while testing on this matter were:

- "d" is not working as expected once you have had some other date in the field (or any field on that form). I just reported this as #19752.
- the issue #19752 rised by Steffen some time ago (+xx shifting time by clients timezone).

Another issue is that the "+XX", "d", "t", "n" syntaxes allowed in these date(time) fields are not documented anywhere, so it is difficult to know what is intended by the original author (Kasper?) and what is a side-effect of the evaluations made.

Actions #11

Updated by Ernesto Baschny almost 16 years ago

This is the intended behaviour (at least it has been like that for ages). So "won't fix".

Actions

Also available in: Atom PDF