Results 1 to 2 of 2

Thread: Ext.Date.isValid function isn't working as expected

  1. #1
    Sencha User viniciuscs's Avatar
    Join Date
    Jan 2012
    Location
    So Paulo / Brazil
    Posts
    8

    Default Answered: Ext.Date.isValid function isn't working as expected

    Code:
    var date = new Date(2012, 1, 1);
    console.log(date.toString());
    console.log(Ext.Date.isValid(date.getFullYear(), date.getMonth(), date.getDate()));
            
    date = Ext.Date.add(date, Ext.Date.MONTH, -1);
    console.log(date.toString());
    console.log(Ext.Date.isValid(date.getFullYear(), date.getMonth(), date.getDate()));
    Result:

    Wed Feb 01 2012 00:00:00 GMT-0200 (E. South America Daylight Time)
    true
    Sun Jan 01 2012 00:00:00 GMT-0200 (E. South America Daylight Time)
    false


    Can someone please explain to me why the second validation fails? thks.

  2. Ext.Date.isValid() checks for a 1-based month-of-year argument, not a 0-based month.
    (see http://docs.sencha.com/ext-js/4-0/#!...method-isValid)

    Code:
    var date = new Date(2012, 1, 1);
    console.log(Ext.Date.isValid(
        date.getFullYear(), 
        date.getMonth(), // month = 1, i.e. January
        date.getDate()
    ));
            
    date = Ext.Date.add(date, Ext.Date.MONTH, -1);
    console.log(Ext.Date.isValid(
        date.getFullYear(), 
        date.getMonth(), // month = 0, i.e. invalid
        date.getDate())
    );

  3. #2
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Answers
    1

    Default

    Ext.Date.isValid() checks for a 1-based month-of-year argument, not a 0-based month.
    (see http://docs.sencha.com/ext-js/4-0/#!...method-isValid)

    Code:
    var date = new Date(2012, 1, 1);
    console.log(Ext.Date.isValid(
        date.getFullYear(), 
        date.getMonth(), // month = 1, i.e. January
        date.getDate()
    ));
            
    date = Ext.Date.add(date, Ext.Date.MONTH, -1);
    console.log(Ext.Date.isValid(
        date.getFullYear(), 
        date.getMonth(), // month = 0, i.e. invalid
        date.getDate())
    );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •