google-code-export / gwt-ext

Automatically exported from code.google.com/p/gwt-ext
0 stars 0 forks source link

com.gwtext.client.widgets.form.DateField returns wrong java.util.Date after 1980 #109

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The DateField widget in com.gwtext.client.widgets.form returns a date
displaced by one hour (displacing the date of the day by one) if a date
after 1980 is selected.

E.g. If Tuesday, September 18, 1956 is selected the DateField will return
Monday, September 17, 1956 (23:00:00) instead.

What steps will reproduce the problem?
--------------------------------------
1. Create a new module with the code supplied below in the onModuleLoad()
2. Select the 20th sept. 2007, observe that the output is correct.
3. Select the 20th sept. 1980, observe that the output is correct.
4. Select the 20th sept. 1979, observe that the output is displaced by one
hour, putting the date in the previous day.

What is the expected output? What do you see instead?
-----------------------------------------------------
The output is expected to be on the 20th sept. on the selected year. The
error occurs for all dates tested after 1980.

What version of the product are you using? On what operating system?
--------------------------------------------------------------------
OS: Windows XP, time zone: CEST.
GWT: 1.4 Final
GWT-EXT: 0.9.2 built from SVN on 2007-09-06 (no changes to DateField has
been added to the SVN since then).

Please provide any additional information below.
------------------------------------------------
Test program: 

Form f = new Form(new FormConfig(){{
  setHideLabels(true);
}});
f.add(new DateField(new DateFieldConfig(){{
  setFieldListener(new FieldListenerAdapter(){
    public void onChange(Field field, Object newVal, Object oldVal){
      GWT.log("New value: " + newVal, null);
      GWT.log("Old value: " + oldVal, null);
    }});
}}));
f.end();
f.render();
RootPanel.get().add(f);

Original issue reported on code.google.com by intern...@gmail.com on 12 Sep 2007 at 10:17

GoogleCodeExporter commented 9 years ago
The following solution fixes the problem.

Original comment by intern...@gmail.com on 12 Sep 2007 at 11:09

Attachments:

GoogleCodeExporter commented 9 years ago
Forgot to update this issue, after testing further the patch above exposes a 
really
funny error in Firefox - if used it will sometimes generate dates with the time 
zone
GMT+200, which, if we were living on Jupiter would be quite reasonable.

The following method of setting the date plays nice with Firefox:

public Date getValue()
{
    JavaScriptObject o = getDateJsObj(jsObj);
    Date date = null;
    if (o != null)
    {
        date = new Date(getFullYear(o) - 1900, getMonth(o), getDate(o));
    }
    return date;
}
private native int getFullYear(JavaScriptObject dt)/*-{
    return dt.getFullYear();
}-*/;
private native int getMonth(JavaScriptObject dt)/*-{
    return dt.getMonth();
}-*/;
private native int getDate(JavaScriptObject dt)/*-{
    return dt.getDate();
}-*/;
private native JavaScriptObject getDateJsObj(JavaScriptObject df)/*-{
    var val = df.getValue(); 
    return (val == '' || val === undefined) ? null : val;
}-*/;

Original comment by intern...@gmail.com on 21 Sep 2007 at 7:58

GoogleCodeExporter commented 9 years ago
I think it might be related to issue 225

http://code.google.com/p/gwt-ext/issues/detail?id=225

Original comment by pgil%agn...@gtempaccount.com on 6 Mar 2008 at 10:53

GoogleCodeExporter commented 9 years ago
This should fix it... Will try to incorporate in in SVN soon.

http://extjs.com/forum/showthread.php?p=167193

Original comment by mlim1...@gmail.com on 30 Sep 2008 at 6:07

GoogleCodeExporter commented 9 years ago
This is still not fixed!!!! See this 
http://www.extjs.com/forum/showthread.php?t=28875&page=4
We are still on gwt-ext-2.0.6 and planning to upgrade to SmartGWT in near 
future. This bug hit us bad and 
our U.S clients have started reporting problems of their critical applications 
crash. Would it be possible for you 
to urgently incorporate this fix and provide a patch for gwt-ext-2.0.6 or 
suggest a workaround. Thanks

Original comment by visha...@gmail.com on 15 Mar 2010 at 1:11