Advertisement
metalx1000

Find which shift you are on firefighting

Sep 16th, 2015
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shift(){
  2.   var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
  3.   var ashift = new Date(2015,08,15);
  4.   var bshift = new Date(2015,08,16);
  5.   var cshift = new Date(2015,08,17);
  6.   var today = new Date();
  7.   today.setHours(0,0,0,0);
  8.  
  9.   var ashift = Math.round(Math.abs((ashift.getTime() - today.getTime())/(oneDay)));
  10.   var bshift = Math.round(Math.abs((bshift.getTime() - today.getTime())/(oneDay)));
  11.   var cshift = Math.round(Math.abs((cshift.getTime() - today.getTime())/(oneDay)));
  12.   //diffDays % 2;
  13.   if(ashift % 3 === 0){
  14.     return "A shift";
  15.   }else if(bshift % 3 === 0){
  16.     return "B shift";
  17.   }else if(cshift % 3 === 0){
  18.     return "C shift";
  19.   }else{
  20.     return "unkown shift";
  21.   }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement