Advertisement
Debugbro

DateFix

Sep 3rd, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <script>
  2. // Startdate is when we open the file
  3. StartDate = parseInt(new Date().getTime());
  4.  
  5.  
  6. // I'll just butcher this function a bit because I haven't defined Game and Beautify
  7. SayTime = function(time,detail)
  8. {
  9. var str='';
  10. var detail=detail||0;
  11. time=Math.floor(time);
  12. if (time>=60*60*24*2 && detail<2) str=time/(60*60*24)+' days';
  13. else if (time>=60*60*24 && detail<2) str='1 day';
  14. else if (time>=60*60*2 && detail<3) str=time/(60*60)+' hours';
  15. else if (time>=60*60 && detail<3) str='1 hour';
  16. else if (time>=60*2 && detail<4) str=time/(60)+' minutes';
  17. else if (time>=60 && detail<4) str='1 minute';
  18. else if (time>=2 && detail<5) str=time/(1)+' seconds';
  19. else if (time>=1 && detail<5) str='1 second';
  20. return str;
  21. }
  22.  
  23.  
  24. // We simulate playtime by watching an alert. Fun.
  25. alert("Please wait a few seconds to close this alert. Count along, too.")
  26.  
  27.  
  28. // Now we calculate the difference before and after the alert.
  29. var date=new Date();
  30. date.setTime(new Date().getTime()-StartDate);
  31.  
  32.  
  33. // We convert the difference to milliseconds with parseInt in the following two steps
  34.  
  35. // We divide the amount of milliseconds by 60 and then write it in base 4. Uhhhh...?
  36. dateORT=SayTime(parseInt(date.getTime())/60,4);
  37.  
  38. // Or we can just divide the amount of milliseconds by 1000 to get seconds.
  39. dateFIX=SayTime(parseInt(date.getTime())/1000);
  40.  
  41.  
  42. document.write("Time passed according to Orteil: "+dateORT+"<br />Time passed like it should be: "+dateFIX)
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement