1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    225
    Vote Rating
    0
    seldon is on a distinguished road

      0  

    Default [2.2] Datefield bug

    [2.2] Datefield bug


    There seems to be a bug in the datefield. Whenever you set a date format for the field that does not include the day (so for example 'Y-m', the selection of a date in february is transformed into a day in march. So in other words, you cannot enter any date in february of any year.

  2. #2
    Ext User speedytangent's Avatar
    Join Date
    Feb 2008
    Location
    Sialkot,Pakistan
    Posts
    51
    Vote Rating
    0
    speedytangent is on a distinguished road

      0  

    Default


    yes.... I also observed a problem with datefiled.

    i set the fromat as "W" , to get the week number of the Date , but every time i changed the week number other then the current week Number ... it changed to the back to current week as the datefiled loosed focus....
    Atta ur Rahman

  3. #3
    Ext User
    Join Date
    Jun 2007
    Posts
    19
    Vote Rating
    0
    netnoise is on a distinguished road

      0  

    Default


    Any news on this one?

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    Did you also change the "altFormats"? They act as backup for parsing of dates and could create the issues mentioned above if left as the default.
    Jack Slocum
    Ext JS Founder
    Original author of Ext JS 1, 2 & 3.
    Twitter: @jackslocum
    jack@extjs.com

  5. #5
    Ext User
    Join Date
    Jun 2007
    Posts
    19
    Vote Rating
    0
    netnoise is on a distinguished road

      0  

    Default


    Just checked it with format and altFormats both set to 'W/Y' and the problem persists.

    After looking at the source of Date.js I found that 'W' isn't set to "contribute to the date calculations". Sadly I have no fix for it, since my own experiments on overriding this function and calculating the date from ISO-Week miserably failed :-)

  6. #6
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    @jack, regarding @seldon's issue, the problem with the datefield is that it stores the string representation (containing incomplete date information) instead of the actual Date object (which correctly encapsulates full date info after parseDate() is called) so a format like 'Y-m', while valid, will result in issues as mentioned by @seldon in post #1 because the day of the month will default to the current day when parsing the stored date string.

    a correct implementation IMHO should simply store the Date object as the datefield's underlying value, and format it appropriately for display in the datefield's <input> element (the DateField will likely need to have getValue()/setValue() handling which is similar to the ComboBox's i.e. a separate display value + underlying value)

    try for example the following datefield code:
    Code:
        new Ext.form.DateField({
            renderTo: document.body,
            format: 'Y-m', // display + parse format
            altFormats: 'Y-m-d|d/m/Y' // acceptable parse formats
        });
    and type in the following date strings (wait till the 30th of November, or adjust your system clock so the current day of month is 30):
    Code:
    2008-12-31 // date string in Y-m-d format
    
    02/02/2008 // date string in d/m/Y format
    Last edited by mystix; 26 Nov 2008 at 6:57 PM. Reason: edit

  7. #7
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by netnoise View Post
    Just checked it with format and altFormats both set to 'W/Y' and the problem persists.

    After looking at the source of Date.js I found that 'W' isn't set to "contribute to the date calculations". Sadly I have no fix for it, since my own experiments on overriding this function and calculating the date from ISO-Week miserably failed :-)
    how exactly does one calculate the date from a single ISO week number?

    or what exactly are you trying to do?

  8. #8
    Ext User
    Join Date
    Jun 2007
    Posts
    19
    Vote Rating
    0
    netnoise is on a distinguished road

      0  

    Default


    Quote Originally Posted by mystix View Post
    how exactly does one calculate the date from a single ISO week number?

    or what exactly are you trying to do?
    Date from first day of year + ((Week number - 1) * 7) Days

    Of course you need both, week number and the year to do that

  9. #9
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by netnoise View Post
    Date from first day of year + ((Week number - 1) * 7) Days

    Of course you need both, week number and the year to do that
    there's still information missing from that formula -- like the day of week.
    which brings me back to my question -- what exactly is the use case for this?

  10. #10
    Ext User
    Join Date
    Jun 2007
    Posts
    19
    Vote Rating
    0
    netnoise is on a distinguished road

      0  

    Default


    Quote Originally Posted by mystix View Post
    there's still information missing from that formula -- like the day of week.
    When format string is 'Y' there's information missing, too. But the year of the date object is set anyway.

    Quote Originally Posted by mystix View Post
    which brings me back to my question -- what exactly is the use case for this?
    I needed a DateField in an editable grid that accepts inputs in format 'W/Y'.