Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    48
    Vote Rating
    1
    rondestvedt is on a distinguished road

      0  

    Default DatePicker doesn't properly respect 4-digit years

    I understand that if a 2-digit year is entered into the date picker, that the century is determined by whether or not the date with the 2-digit year is in the next 20 years.

    But if a 4-digit year is entered which is more than 20 years in the future, for example 5/12/2038, and I persist the value it is persisted correctly as 5/12/2038. However, when I then pop up the date picker 5/12/1938 displays, just as if I had entered 5/12/38 instead of 5/12/2038. The date picker should respect the century since it appears to be known.

  2. #2
    Sencha User
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    212
    Vote Rating
    24
    Andreas Samjeske will become famous soon enough Andreas Samjeske will become famous soon enough

      0  

    Default

    Quote Originally Posted by rondestvedt View Post
    I understand that if a 2-digit year is entered into the date picker, that the century is determined by whether or not the date with the 2-digit year is in the next 20 years.

    But if a 4-digit year is entered which is more than 20 years in the future, for example 5/12/2038, and I persist the value it is persisted correctly as 5/12/2038. However, when I then pop up the date picker 5/12/1938 displays, just as if I had entered 5/12/38 instead of 5/12/2038. The date picker should respect the century since it appears to be known.
    I am unable to reproduce the problem in the examples or my own webapp (german locale).

    Which version of GXT are you using?
    This problem might be locale-depending. Which locale are you using?
    I guess, there is a DateField involved. Which format does the propEditor have?

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    48
    Vote Rating
    1
    rondestvedt is on a distinguished road

      0  

    Default

    We are using version 3.1.0, with English-US as the locale. Yes, there is a DateField and I'm not setting the property editor so it's using the default with format PredefinedFormat.DATE_SHORT.

  4. #4
    Sencha User
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    212
    Vote Rating
    24
    Andreas Samjeske will become famous soon enough Andreas Samjeske will become famous soon enough

      1  

    Default

    Quote Originally Posted by rondestvedt View Post
    We are using version 3.1.0, with English-US as the locale. Yes, there is a DateField and I'm not setting the property editor so it's using the default with format PredefinedFormat.DATE_SHORT.
    Right. I used a plain DateField of GXT 3.1.0 and have been able to reproduce your problem:
    - Select a Date more then 20 years in future, like 1/1/2038, via Datepicker
    - DateField shows 1/1/38, since DATE_SHORT is default format.
    - Open Datepicker again and you see it is January 1st, 1938.

    But I don't consider this a bug of Datepicker. Datepicker is just a nice presenter and choosing element of Dates. And I don't think DateField ist doing something wrong, either. What do you expect of DateField with PredefinedFormat.DATE_SHORT? It is doing its best guess on 2digit years.

    The problem I see is this: PredefinedFormat.DATE_SHORT should not be the default for Datefield! 2-digit year has its problems. If someone explicitly set 2-digit year, he has to deal with it.

    Seems like this has changed recently. The form example (GXT 3.1.3) doesn't set a format for the field, but it still has a 4-digit year. You should consider doing this, too:
    Code:
            DateField df = new DateField();
            df.setPropertyEditor(new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM)));

Thread Participants: 1