Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- var shift = getShift();
- document.addEventListener("DOMContentLoaded", function(event) {
- document.getElementById("shift").innerHTML = "Today is a " + shift;
- });
- function getShift(){
- var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
- var ashift = new Date(2015,8,15);
- var bshift = new Date(2015,8,16);
- var cshift = new Date(2015,8,17);
- var today = new Date();
- today.setHours(0,0,0,0);
- ashift = Math.round(Math.abs((ashift.getTime() - today.getTime())/(oneDay)));
- bshift = Math.round(Math.abs((bshift.getTime() - today.getTime())/(oneDay)));
- cshift = Math.round(Math.abs((cshift.getTime() - today.getTime())/(oneDay)));
- //diffDays % 2;
- if(ashift % 3 === 0){
- return "A shift";
- }else if(bshift % 3 === 0){
- return "B shift";
- }else if(cshift % 3 === 0){
- return "C shift";
- }else{
- return "unkown shift";
- }
- }
- </script>
- </head>
- <body>
- <h1 id="shift"></h1>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement