Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    JSCoder is on a distinguished road

      0  

    Post [CLOSED][3.0.0] Date parsing and formatting not turned off.

    [CLOSED][3.0.0] Date parsing and formatting not turned off.


    On a form dateField, parsing is NOT fully turned off when using Date.useStrict = true
    Some of it is turned off, but the cases: 1/1/1, 2/2/2 i.e. n/n/n are not turned off. I'm
    guessing more corner cases of various formats will be there.

    1/1/1 gets formatted into 01/01/2001 and so on.

    Code:
            Date.useStrict = true;
            
            var dateBoxes = Ext.DomQuery.select("input.date");
            var today = (new Date()).clearTime();
    
            Ext.each(dateBoxes, function(item, id, all){   
                var cl = new Ext.form.DateField({   
                        allowBlank : true,
                        applyTo: item,
                        hideTrigger: (item.readOnly || item.disabled),
                        minValue: (item.readOnly || item.disabled)?'01/01/0001':today,
                        validationDelay: 40,
                        maskRe: /\d|\//,
                        useStrict: true
                   });
                   cl.validate();
            });

  2. #2
    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


    what do you mean by "not turned off"?

    as long as your date string matches either the format config or any of the other formats in the altFormats config, it will be parsed.

    1/1/1 and 2/2/2 are both valid date strings.

  3. #3
    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


    to add on:
    since 1/1/1 and 2/2/2 are both valid date strings (i.e. they match either the format config or one of the date formats in the altFormats config for the datefield), they will be parsed according to the conditions stipulated in the docs for parseDate.

    i.e. "The defaults hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond) which cannot be found in the passed string. If a corresponding default date value has not been specified in the defaults hash, the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.".

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I think the question is, should 2/2/2 actually match d/m/Y, d/m/y, n/j/Y or n/j/y in strict mode?

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,945
    Vote Rating
    636
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The way it works now is that it will attempt to parse them in order, of format then altFormats.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Quote Originally Posted by evant View Post
    The way it works now is that it will attempt to parse them in order, of format then altFormats.
    Let me rephrase that:
    Should '2' match 'd', 'm' or 'y' (it doesn't have 2 digits) or 'Y' (it doesn't have 4 digits).

    --- strict mode only off course ---

  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 Condor View Post
    Let me rephrase that:
    Should '2' match 'd', 'm' or 'y' (it doesn't have 2 digits) or 'Y' (it doesn't have 4 digits).
    ouch. that's going to hurt real bad.

  8. #8
    Ext User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    JSCoder is on a distinguished road

      0  

    Default


    Allow me put forward a simple behavior:

    When a date (or a string for that matter) is typed into a dateField, it's surely within EXTJS' responsibility to check its validity.

    But what if one requires a dateField which will not alter the content which is typed into the dateField (under any condition)? Surely, if a person types in 2/2/2 or 1/1/1 under strict mode, why should it be converted to anything at all?

    I'd imagine a configurable flag : reformat: false, otherwise this is obtrusive behavior. Correct me if I'm wrong, but for functionalities like these, the configurability should be atomic.

    I don't mean to diminish the efforts that the development team has already put into making this release, I mean, the volume, depth and beadth of the library speaks for itself, but I just personally feel that this is something which is too basic to be missed.

    Silly me would imagine something like this:

    Code:
    var cl = new Ext.form.DateField({   
              allowBlank : true,
              applyTo: item,
              hideTrigger: (item.readOnly || item.disabled),
              minValue: (item.readOnly || item.disabled)?'01/01/0001':today,
              validationDelay: 40,
              maskRe: /\d|\//,
              reformat: false
    });

  9. #9
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,945
    Vote Rating
    636
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You're misunderstanding what the strict option does. Strict basically stops the rolling over of dates, which is the automatic behaviour of the javascript date objects. You're talking about something completely different. By default the date field is configured with a format and then a series of alternate formats, so when an input is entered it attempts to parse the value to get a date out of it. You could clear the altFormats to ensure that the date can only be inputted in the format you've specified.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  10. #10
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    No response in some time, can this be updated to CLOSED?