Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
4 replies Latest Post - ‏2010-11-11T21:12:44Z by SystemAdmin
SystemAdmin
SystemAdmin
238 Posts
ACCEPTED ANSWER

Pinned topic Get Local Time on the appliance

‏2010-11-03T18:39:24Z |

Is there any way to get the Local Tiem on the Appliance and not GMT ?The Get Current Date / Time functions all return GMT. If I use Read Date and specify the Locale, that does not give me the resulting xsd:dateTime based on the locale.The JobInfo.jobStartTime is also a GMT locale. What I am trying to achieve is: Convert UTC milliseconds to Local time on appliance. 
Updated on 2010-11-11T21:12:44Z at 2010-11-11T21:12:44Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    238 Posts
    ACCEPTED ANSWER

    Get Local Time

    ‏2010-11-03T21:36:11Z  in response to SystemAdmin
    You will need to create a custom function to return the data/time correctly. 
     
    var myDate = new Date(gmtDate);
    var myNewDate;

    ///////////////////////////////////////////
    /////check if Daylight Savings is true/////
    ///////////////////////////////////////////
    var isDLS = "false";
    var gmt = new Date;
    var ssm = new Date;
    var fsn = new Date;
    var aDay = 1000 * 60 * 60 * 24;

    ssm.setMonth(2); // Starts on Second Sunday in March
    ssm.setDate(1);

    var counter = 0;

    for(i=0;i<15;i++) {<br />
    if( counter == 2 ) { break; }
    if( ssm.getDay() == 6 ) { counter ++; }
    ssm.setTime(ssm.getTime() + aDay);
    }

    fsn.setMonth(10); // Ends on First Sunday in November
    fsn.setDate(1);

    for(i=0;i<7;i++) {<br />
    if( fsn.getDay() == 6 ) {break; }
    fsn.setTime(fsn.getTime() + aDay);
    }

    if (gmt < ssm || gmt >= fsn) {
    isDLS = "false";
    } else {
    isDLS = "true";
    }
    ///////////////////////////////////////////
    //////check for Daylight Savings ends//////
    ///////////////////////////////////////////


    //Set PST Hour differece based on Day Light Saving
    var Hours;

    if (isDLS == 'true') {
    Hours = '7';
    } else if (isDLS == 'false') {
    Hours = '8';
    }

    myDate.setTime (myDate.getTime() - (myDate.getTimezoneOffset()+(Hours*60))*60*1000);

    myNewDate = new Date((myDate.getTime()));

    var myYear = myNewDate.getUTCFullYear();
    if (myYear < 1000)<br />
    myYear += 1900;

    var myMonth = myNewDate.getUTCMonth() + 1;
    if (myMonth < 10)<br />
    myMonth = "0" + myMonth;

    var myDay = myNewDate.getUTCDate();
    if (myDay < 10)<br />
    myDay = "0" + myDay;

    var myHH = myNewDate.getUTCHours();
    var initHH = myHH;
    if (myHH < 10)<br />
    myHH = "0" + myHH;

    var myMM = myNewDate.getUTCMinutes();
    if (myMM < 10)<br />
    myMM = "0" + myMM;

    var mySS = myNewDate.getUTCSeconds();
    if (mySS < 10)<br />
    mySS = "0" + mySS;

    var resultat = myYear + "" + myMonth + "" + myDay + " AT " + myHH + '-' + myMM + '-' + mySS;

    return (resultat);
  • SystemAdmin
    SystemAdmin
    238 Posts
    ACCEPTED ANSWER

    getLocalTime

    ‏2010-11-03T23:52:02Z  in response to SystemAdmin

    Thanks J,Although this solution is more of a hack.There should be a GetLocalTime function that gives a local time on the appliance (either rely local system time / call Calendar Service to get Locale based Time) can this be made into a feature request ? 
  • SystemAdmin
    SystemAdmin
    238 Posts
    ACCEPTED ANSWER

    Change the time zone

    ‏2010-11-08T19:42:13Z  in response to SystemAdmin
    Have you tried going in through ssh (or telnet) and using the CLI command, time set zone America/reference city in your time zone (for example, time set zone America/Chicago)? Once you are no longer based on GMT you may have better luck.
  • SystemAdmin
    SystemAdmin
    238 Posts
    ACCEPTED ANSWER

    Appliance Time Zone

    ‏2010-11-11T21:12:44Z  in response to SystemAdmin

    Thanks John, That makes sense.