1. #1
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    37
    Vote Rating
    0
    bortron5000 is on a distinguished road

      0  

    Question Answered: Ext.Date.add and Datepicker

    Answered: Ext.Date.add and Datepicker


    Hello all,

    I'm having some problems using the datepicker in conjuction with the Ext.Date.add function. I presently have a datepicker field for an original date, a field that accepts an interval (1 year, 4 months etc), and another datepicker field that should be populated with a new date, equal to the first date plus the interval.

    There are no errors, but the value that's appearing in the final date field is doing very bizarre things. If the interval is a month amount it seems to work. However, if I try to add a year amount, it will append the amount to the end of the year (1/1/2012 becomes 1/1/20121), and if I add an amount of days, everything seems to change unpredictably.

    The code in my controller is as follows

    Code:
      calcNext: function(){
        var form = Ext.getCmp('screentypeform'),
            last = form.down('#last').getValue(),
            interval = form.down('#interval').getValue(),
            next = form.down('#next');
        
        if(!last || !interval){
            return;
        }
        
        var intArray = interval.split(" "),
            amt = intArray[0],  //Numeric value
            step = intArray[1].toLowerCase();  //Day, month or year
        
        if(step == "day" || step == "days"){
            next.setValue(Ext.Date.add(last, Ext.Date.DAY, amt));
        }
        else if(step == "month" || step == "months"){
            next.setValue(Ext.Date.add(last, Ext.Date.MONTH, amt));
        }
        else if(step == "year" || step == "years"){
            next.setValue(Ext.Date.add(last, Ext.Date.YEAR, amt));
        }
      }
    I have a feeling it has something to do with my initial date formatting, but since I'm getting and setting the values directly from the datepicker fields, I'd have thought that would not be an issue. I've already ensured that the fields have values and that the interval is the correct formatting. Thanks in advance!

  2. In PR3 this is working for me:

    Code:
    var date    = new Date(),
        newDate = Ext.Date.add(date, Ext.Date.YEAR, 1);
    
    console.log(Ext.Date.format(newDate, 'm/d/Y'));
    What is the value of last and amt?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,732
    Answers
    3364
    Vote Rating
    756
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    In PR3 this is working for me:

    Code:
    var date    = new Date(),
        newDate = Ext.Date.add(date, Ext.Date.YEAR, 1);
    
    console.log(Ext.Date.format(newDate, 'm/d/Y'));
    What is the value of last and amt?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    37
    Vote Rating
    0
    bortron5000 is on a distinguished road

      0  

    Default


    Aha, amt is being interpreted as a string, since I split it from a string I guess. If I parse it into an int it works Although I do wonder why it didn't have a problem with months...

    Thanks for the assistance.

    P.S. there should be a face-palm smiley face.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,732
    Answers
    3364
    Vote Rating
    756
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by bortron5000 View Post
    P.S. there should be a face-palm smiley face.
    100% about this I have had many of those moments myself
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar