This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!

Respecting the Craft

By: flammon on Jan 9th, 2013  |  syntax: JavaScript  |  size: 4.82 KB  |  views: 55  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function myfunction(order_date)
  2. {
  3. //Find here Lunch days.......
  4. var launch_day = new Date(order_date*1000);
  5.  
  6. var dd = launch_day.getDate();
  7.  
  8. var mm = launch_day.getMonth()+1; //January is 0!
  9.  
  10. var yyyy = launch_day.getFullYear();
  11. // will display time in 10:30:23 format
  12. var lunchdate = yyyy+'-'+mm+'-'+dd;
  13.  
  14. var weekday=new Array(7);
  15. weekday[0]="Sunday";
  16. weekday[1]="Monday";
  17. weekday[2]="Tuesday";
  18. weekday[3]="Wednesday";
  19. weekday[4]="Thursday";
  20. weekday[5]="Friday";
  21. weekday[6]="Saturday";
  22. var compare_lunchdate = weekday[launch_day.getDay()]; //this is lunch days
  23.  
  24. //  Find here Current day..............
  25. var current_day = new Date();
  26.  
  27. var current_weekday=new Array(7);
  28. current_weekday[0]="Sunday";
  29. current_weekday[1]="Monday";
  30. current_weekday[2]="Tuesday";
  31. current_weekday[3]="Wednesday";
  32. current_weekday[4]="Thursday";
  33. current_weekday[5]="Friday";
  34. current_weekday[6]="Saturday";
  35. var compare_current_day = current_weekday[current_day.getDay()]; //this is Current  days
  36. //alert(compare_current_day=="Saturday")
  37. if(compare_current_day=="Saturday")
  38. {
  39.           var today = new Date();
  40.       var adddays=Date.parse(today.setDate(today.getDate()+ 2));
  41.       var dd = adddays.getDate();
  42.  
  43. var mm = adddays.getMonth()+1; //January is 0!
  44.  
  45. var yyyy = adddays.getFullYear();
  46. // will display time in 10:30:23 format
  47. var checkdays = yyyy+'-'+mm+'-'+dd;
  48.      
  49.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  50.       {
  51.         return true;
  52.       }
  53.       else
  54.       {
  55.         alert("Sorry you cannot edit !");
  56.         return false;
  57.       }
  58.      
  59.    
  60. }
  61.    
  62. if(compare_current_day=="Sunday")
  63. {
  64.           var today = new Date();
  65.       var adddays=Date.parse(today.setDate(today.getDate()+ 1));
  66.       var dd = adddays.getDate();
  67.  
  68. var mm = adddays.getMonth()+1; //January is 0!
  69.  
  70. var yyyy = adddays.getFullYear();
  71. // will display time in 10:30:23 format
  72. var checkdays = yyyy+'-'+mm+'-'+dd;
  73.      
  74.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  75.       {
  76.         return true;
  77.       }
  78.       else
  79.       {
  80.         alert("Sorry you cannot edit !");
  81.         return false;
  82.       }
  83.      
  84.    
  85. }
  86.  
  87. if(compare_current_day=="Monday")
  88. {
  89.           var today = new Date();
  90.       var adddays=Date.parse(today.setDate(today.getDate()+ 1));
  91.       var dd = adddays.getDate();
  92.  
  93. var mm = adddays.getMonth()+1; //January is 0!
  94.  
  95. var yyyy = adddays.getFullYear();
  96. // will display time in 10:30:23 format
  97. var checkdays = yyyy+'-'+mm+'-'+dd;
  98.      
  99.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  100.       {
  101.         return true;
  102.       }
  103.       else
  104.       {
  105.         alert("Sorry you cannot edit !");
  106.         return false;
  107.       }
  108.      
  109.    
  110. }
  111.  
  112.  
  113. if(compare_current_day=="Tuesday")
  114. {
  115.           var today = new Date();
  116.       var adddays=Date.parse(today.setDate(today.getDate()+ 1));
  117.       var dd = adddays.getDate();
  118.  
  119. var mm = adddays.getMonth()+1; //January is 0!
  120.  
  121. var yyyy = adddays.getFullYear();
  122. // will display time in 10:30:23 format
  123. var checkdays = yyyy+'-'+mm+'-'+dd;
  124.      
  125.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  126.       {
  127.         return true;
  128.       }
  129.       else
  130.       {
  131.         alert("Sorry you cannot edit !");
  132.         return false;
  133.       }
  134.      
  135.    
  136. }
  137.  
  138. if(compare_current_day=="Wednesday")
  139. {
  140.           var today = new Date();
  141.       var adddays=Date.parse(today.setDate(today.getDate()+ 1));
  142.       var dd = adddays.getDate();
  143.  
  144. var mm = adddays.getMonth()+1; //January is 0!
  145.  
  146. var yyyy = adddays.getFullYear();
  147. // will display time in 10:30:23 format
  148. var checkdays = yyyy+'-'+mm+'-'+dd;
  149.      
  150.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  151.       {
  152.         return true;
  153.       }
  154.       else
  155.       {
  156.         alert("Sorry you cannot edit !");
  157.         return false;
  158.       }
  159.      
  160.    
  161. }
  162. if(compare_current_day=="Thursday")
  163. {
  164.           var today = new Date();
  165.       var adddays=Date.parse(today.setDate(today.getDate()+ 3));
  166.       var dd = adddays.getDate();
  167.  
  168. var mm = adddays.getMonth()+1; //January is 0!
  169.  
  170. var yyyy = adddays.getFullYear();
  171. // will display time in 10:30:23 format
  172. var checkdays = yyyy+'-'+mm+'-'+dd;
  173.      
  174.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  175.       {
  176.         return true;
  177.       }
  178.       else
  179.       {
  180.         alert("Sorry you cannot edit !");
  181.         return false;
  182.       }
  183.      
  184.    
  185. }
  186. if(compare_current_day=="Friday")
  187. {
  188.           var today = new Date();
  189.       var adddays=Date.parse(today.setDate(today.getDate()+ 3));
  190.       var dd = adddays.getDate();
  191.  
  192. var mm = adddays.getMonth()+1; //January is 0!
  193.  
  194. var yyyy = adddays.getFullYear();
  195. // will display time in 10:30:23 format
  196. var checkdays = yyyy+'-'+mm+'-'+dd;
  197.      
  198.       if((Date.parse(checkdays))< (Date.parse(lunchdate)))
  199.       {
  200.         return true;
  201.       }
  202.       else
  203.       {
  204.         alert("Sorry you cannot edit ! ");
  205.         return false;
  206.       }
  207.      
  208.    
  209. }
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216. }
clone this paste RAW Paste Data