SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member Ppecher's Avatar
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date object - need value assignment not reference

    The goal is for selectedDay to be assigned the value of the system variable Mainpackage.subclass0.subclass1.firstDay and then incremented by two days. Mainpackage.subclass0.subclass1.firstDay needs to be unchanged.

    Important system variable in red.
    To be 'manipulated and used' variable in green.
    Even with an intermediary, third, dummy variable it doesn't work:

    Code:
        
    //Declarations and instantiations
        var systemDate = new Date();
        var selectedDay = new Date();
        Mainpackage.subclass0.subclass1.firstDay;
    //Assignments and manipulations
        systemDate = Mainpackage.subclass0.subclass1.firstDay;
        selectedDay = systemDate;
        selectedDay.setDate(selectedDay.getDate()+2);
    //Logging
        console.log('Mainpackage.subclass0.subclass1.firstDay: ' +Mainpackage.subclass0.subclass1.firstDay +'\n' +'systemDate: ' +systemDate +'\n' +'selectedDay :' +selectedDay +'\n');
    Console log is:
    Code:
    Mainpackage.subclass0.subclass1.firstDay: Tue Aug 24 2010 00:00:00 GMT-0400 (Eastern Daylight Time) 
    systemDate: Tue Aug 24 2010 00:00:00 GMT-0400 (Eastern Daylight Time) 
    selectedDay: Tue Aug 24 2010 00:00:00 GMT-0400 (Eastern Daylight Time)
    It doesn't work in my webapp : All variables change at the same time.

  2. #2
    SitePoint Member Ppecher's Avatar
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EDIT: Resolved


Bookmarks

Posting Permissions

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