Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // a_value = "04:22:00"; hh:mm:ss
- // b_value = "06:13:10"; hh:mm:ss
- function time_calculation(a_value, b_value)
- {
- var hour = 0;
- var minute = 0;
- var second = 0;
- var splitTime1 = a_value.toString().split(':');
- var splitTime2 = b_value.toString().split(':');
- hour = parseInt(check_Int(splitTime1[0]))+parseInt(check_Int(splitTime2[0]));
- minute = parseInt(check_Int(splitTime1[1]))+parseInt(check_Int(splitTime2[1]));
- hour = hour + minute/60;
- hour = Math.floor(hour); // Extra Add
- minute = minute%60;
- second = parseInt(check_Int(splitTime1[2]))+parseInt(check_Int(splitTime2[2]));
- minute = minute + second/60;
- second = second%60;
- const zeroPad = (num, places) => String(num).padStart(places, '0');
- return zeroPad(hour, 2)+':'+zeroPad(minute, 2)+':'+zeroPad(second, 2);
- }
- function check_Int(argument)
- {
- if(argument % 1 === 0){
- return argument;
- }else{
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement