Liquid UI - WS Reference Library

Convert time from milliseconds to days/hours/minutes/seconds.


Prerequisites


Purpose

Convert milliseconds to Days/Hours/Minutes/Seconds depending on milliseconds value.


User Interface

Log into SAP and on the SAP Easy Access Screen. Enter the time in milliseconds and click on the ‘Convert milliseconds’ pushbutton.



Liquid UI Script

//SAPLSMTR_NAVIGATION.E0100.sjs

// Function to convert milliseconds to Days/Hours/Minutes/Seconds depending on milliseconds value
function timeConversion(millisec) {
    var seconds = (millisec / 1000).toFixed(2);
    var minutes = (millisec / (1000 * 60)).toFixed(2);
    var hours = (millisec / (1000 * 60 * 60)).toFixed(2);
    var days = (millisec / (1000 * 60 * 60 * 24)).toFixed(2);

    if (seconds < 60) {
        return seconds + " Sec";
    } else if (minutes < 60) {
        return minutes + " Min";
    } else if (hours < 24) {
        return hours + " Hrs";
    } else {
        return days + " Days"
    }
}    

function convertMilliseconds(){
    var res = timeConversion(z_milliseconds);
    set('V[z_converted_ms]','&V[res]');
    return;
}

// User Interface
clearscreen();
inputfield([1,0], "Enter time in milliseconds", [1,28], {"size":10, "name":"z_milliseconds"});
inputfield([2,0], "Milliseconds converted to ", [2,28], {"size":10, "name":"z_converted_ms", "readonly":true});
pushbutton([3,7],"@01@Convert milliseconds", "?", {"process":convertMilliseconds});

Was this information helpful? Send Feedback