Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. var FirstTime = container.find('#1time').val();
  2. var SecondTime = container.find('#2time').val();
  3.  
  4. var busyTimes = [];
  5. busyTimes = getBusyTimes(FirstTime , SecondTime);
  6.  
  7. function getBusyTimes(first, second) {
  8. var f = first.split(' '), s = second.split(' ');
  9. if (first == '12.00 AM') f[0] = '0';
  10. if (first == '12.00 PM') f[1] = 'AM';
  11. if (second == '12.00 AM') s[0] = '24';
  12. if (second == '12.00 PM') s[1] = 'AM';
  13. f[0] = parseInt(f[0], 10) + (f[1] == 'PM' ? 12 : 0);
  14. s[0] = parseInt(s[0], 10) + (s[1] == 'PM' ? 12 : 0);
  15. int i = s[0] - f[0];
  16. // I have difference in hours in "i"
  17. //From here, I want to make use of value 'i' -- calculate in between
  18. // hourly values and return the array back to
  19. // original function above.
  20. }
  21.  
  22. function getBusyTimes(first, second){
  23. var timeList = ['12:00 AM','1:00 AM','2:00 AM','3:00 AM']; // finish this list
  24. var firstid = timeList.indexOf(first);
  25. var secondid = timeList.indexOf(second);
  26. var result = new Array();
  27. for(var i=firstid; i<=secondid; i++ ){
  28. result.push(timeList[i]);
  29. }
  30. return result;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement