CompanyOnwership_icon
Team Nexllence
Created on 29 November 2021
icon_unfollowing
Login to follow
elapsed-time

Elapsed Time

Stable version 1.0.1 (Compatible with OutSystems 11)
Uploaded on 17 December 2021 by 
Team Nexllence
elapsed-time

Elapsed Time

5 star
5
0 Reviews |  5 Ratings
4 star
0
0 Reviews |  0 Ratings
3 star
1
1 Review |  1 Rating
2 star
0
0 Reviews |  0 Ratings
1 star
0
0 Reviews |  0 Ratings
6
Ratings
4.7 Average rating
1
Review
by 
2023-10-27
in version 1.0.1
A good starting point, but the hours would not calculate anything over a day for me. It would just roll over since the code did not account for the date. I have fixed this for my purpose, and now I can show days when the hours gets >=24.

In the OnInitialize I revised the code to:
var endTime;
var timeDiff;
var seconds;
var minutes;
var hours;

elapsedTimeIntervalRef = setInterval(function() {
    // Process current date-time
    endTime = new Date();
    timeDiff = endTime - $parameters.StartDateTime; // Get the time difference in milliseconds
   
    // Calculate elapsed hours, minutes, and seconds
    hours = Math.floor(timeDiff / 3600000); // 1 hour = 3600000 milliseconds
    timeDiff %= 3600000;
    minutes = Math.floor(timeDiff / 60000); // 1 minute = 60000 milliseconds
    timeDiff %= 60000;
    seconds = Math.floor(timeDiff / 1000); // 1 second = 1000 milliseconds

    $actions.RefreshElapsedTime(hours, minutes, seconds);
}, 1000);

In the onReady I revised the code to:
var endTime;
var timeDiff;
var seconds;
var minutes;
var hours;

elapsedTimeIntervalRef = setInterval(function() {
    // Process current date-time
    endTime = new Date();
    timeDiff = endTime - $parameters.StartDateTime; // Get the time difference in milliseconds
   
    // Calculate elapsed hours, minutes, and seconds
    hours = Math.floor(timeDiff / 3600000); // 1 hour = 3600000 milliseconds
    timeDiff %= 3600000;
    minutes = Math.floor(timeDiff / 60000); // 1 minute = 60000 milliseconds
    timeDiff %= 60000;
    seconds = Math.floor(timeDiff / 1000); // 1 second = 1000 milliseconds

    $actions.RefreshElapsedTime(hours, minutes, seconds);
}, 1000);