wcx6298 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

DateTime returning wron time by different acces #627

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

there is problem with DateTime in latest SmartGwt version (2.5). Case similar 
to issue "returning previos date by DateTime component". But, bug is in getting 
value, not displaying them. Below are steps reproducing problem:

1. Set any date in DateTime component
2. Try to get them in client code like given sample

public void dateTimeBug() {
    //given
    DynamicForm form = new DynamicForm();
    DateItem birthDate = new DateItem(DATE_TO_CHECK_KEY, "");
    form.setFields(birthDate);
    birthDate.setValue(new Date(2011, 9, 20));
    //when
    Map valuesAsMap = form.getValues();
    Criteria valuesAsCriteria = form.getValuesAsCriteria();
    Record valuesAsRecord = form.getValuesAsRecord();
}

3. valuesAsMap have date 2011-09-20
   valuesAsCriteria and valuesAsRecord have date one day ealrier: 2011-09-19

It makes dificult (e.g.) to fetch data in list grid with criteria specified in 
form

listgrid.fetchData(dynamicForm.getValuesAsCriteria());

where we always get date one day earlier.

Tested in FireFox 6

regards,
mdaleki

Original issue reported on code.google.com by mateusz....@javart.eu on 17 Sep 2011 at 1:21

GoogleCodeExporter commented 9 years ago
I notice another case. Maybe it helps in fix

Map valuesAsMap = form.getValues();
//valuesAsMap have 2011-09-20
JavaScriptObject jso = JSOHelper.convertMapToJavascriptObject(valuesAsMap);
//jso have date one day earlier 2011-09-19
String jsv = JSON.encode(jso);
//jsv has date 2011-09-19

Original comment by mateusz....@javart.eu on 17 Sep 2011 at 1:54

GoogleCodeExporter commented 9 years ago
If you just toString() a datetime value or likewise look at it under a 
debugger, it will be formatted according to your browser or IDE timezone, or 
may show internal information if it's intended as a "date" value with no 
meaningful time component.  

To validly report a bug, you must specifically use the formatter functions 
provided by SmartGWT and/or demonstrate that a SmartGWT component displays the 
wrong value (but no such bug exists so far as we know).

If you submit a new, correct test case we'll mark the bug valid again.

Original comment by smartgwt...@gmail.com on 19 Sep 2011 at 4:23

GoogleCodeExporter commented 9 years ago
so if I use dynamicForm.getValuesAsCriteria() I can't be sure of the correct 
date?

I have a grid and the form where I specify criteria on which I want fetchData 
in the listgrid.

Original comment by mateusz....@javart.eu on 19 Sep 2011 at 5:12

GoogleCodeExporter commented 9 years ago
Again, the problem is specifically how you're looking at the values, which you 
haven't shown.  Show a test case that indicates that SmartGWT is getting the 
value wrong in it's own format or display, and that would be a valid bug report.

Original comment by smartgwt...@gmail.com on 19 Sep 2011 at 5:26

GoogleCodeExporter commented 9 years ago
OK, attached file (Entry point) with a sample where using only smart-gwt code 
and reproducing problem with date minus one day. There is simple form, button 
and listgrid. Set values in the form e.g. name=xxx, birthdate=20011-09-30, 
click button and see what date is in alert (SC.say()) and what date is in url 
which try to request resource. In both the date is minus one day to given in 
form

Original comment by mateusz....@javart.eu on 30 Sep 2011 at 3:06

Attachments:

GoogleCodeExporter commented 9 years ago
and one more: there is no toString(), no debugging, only smartgwt code used.

Original comment by mateusz....@javart.eu on 30 Sep 2011 at 3:09

GoogleCodeExporter commented 9 years ago
also giving a screenshot

Original comment by mateusz....@javart.eu on 30 Sep 2011 at 3:16

Attachments:

GoogleCodeExporter commented 9 years ago
This code is also incorrect.  For a field of type "date", the time value is 
stored as noon and should be ignored.  When serialized to JSON in the absence 
of a DataSource to provide any type information for fields, this time value is 
included.  If you declare the field as type "date" in the RestDataSource it 
would be omitted.

In the JSONEncoder, in the absence of any type information for the value, 
SmartGWT serializes as UTC.  Your timezone appears to be far enough from GMT to 
actually change the day value.

Original comment by smartgwt...@gmail.com on 4 Oct 2011 at 12:33