Guest User

Untitled

a guest
Nov 15th, 2020
2,263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. var millisDigits = 2; //How many digits the milliseconds should have
  4. const date= "Nov 16, 2020 19:14:30"; //Date to count up from
  5. //-------------------------
  6. var timer = 0;
  7. var mins;
  8. var seconds;
  9. var hours;
  10. var millis;
  11. export function update(value) {
  12.     if(timer<0){
  13.     console.log(timer)
  14.    
  15.     timer+= engine.frametime;
  16.    
  17.     seconds = Math.abs(timer%60|0);
  18.     mins = Math.abs((timer/60)%60|0);
  19.     hours = Math.abs(timer/3600|0);
  20.     millis = Math.abs((timer%1).toFixed(millisDigits).toString().split(".")[1]);
  21.     if(mins<10){
  22.         mins = "0"+mins;
  23.     }
  24.    
  25.     if(seconds <10){
  26.         seconds = "0"+seconds;
  27.     }
  28.     if(hours<10){
  29.         hours = "0"+hours;
  30.     }
  31.     if(millis<10){
  32.         millis = "0"+millis;
  33.     }
  34.    
  35.     return hours+":"+ mins+":"+seconds+":"+millis;
  36.     }
  37.     return "00:00:00:00";
  38. }
  39. /**
  40.  * @param {String} value - for property 'text'
  41.  */
  42. export function init(value) {
  43.     timer= (new Date().getTime()-new Date(date).getTime())/1000;
  44.  
  45.     return value;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment