Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. var schedule = {
  2. Danny: [
  3. { from: 'ПН 12:00+5', to: 'ПН 17:00+5' },
  4. { from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
  5. ],
  6. Rusty: [
  7. { from: 'ПН 11:30+5', to: 'ПН 16:30+5' },
  8. { from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
  9. ],
  10. Linus: [
  11. { from: 'ПН 00:00+3', to: 'ПН 14:00+3' },
  12. { from: 'ПН 21:00+3', to: 'ВТ 09:30+3' },
  13. { from: 'СР 09:30+3', to: 'СР 15:00+3' }
  14. ]
  15. };
  16. var bankHours = {
  17. from: '10:00+2',
  18. to: '18:00+2'
  19. };
  20.  
  21. function Nowdays(schedule, workingHours) {
  22. var time = parse_(schedule, workingHours);
  23. var time_news = {
  24. mon : [],
  25. tue : [],
  26. wes : [],
  27. };
  28. var time_newe = [];
  29. time.forEach(function(item, i, time) {
  30. item.forEach(function(elem, j, item) {
  31. time_news.push(new Date(2016, 9, 17, elem.split('to')[0].split(' ')[1].split(':')[0], elem.split('to')[0].split(' ')[1].split(':')[1]));
  32. time_newe.push(new Date(2016, 9, 17, elem.split('to')[1].split(' ')[1].split(':')[0], elem.split('to')[1].split(' ')[1].split(':')[1]));
  33. });
  34. time_news.push('next');
  35. time_newe.push('next');
  36. });
  37.  
  38. return [time_news, time_newe];
  39. }
  40.  
  41. function lol(schedule, bankHours, arr) {
  42. var hourL = schedule.Linus[0].from.split('+')[1];
  43. var hourB = bankHours.from.split('+')[1];
  44. var arr = schedule.Linus;
  45. var res = [];
  46. var days = ["ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС", "ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС", "ПН"];
  47. if (hourL != hourB) {
  48. arr.forEach(function(item, i, arr) {
  49. k = Number(item.from.split(' ')[1].split(':')[0]) + (Number(hourB) - Number(hourL));
  50. l = Number(item.to.split(' ')[1].split(':')[0]) + (Number(hourB) - Number(hourL));
  51. dayk = item.from.split(' ')[0];
  52. dayl = item.to.split(' ')[0];
  53. if (k < 0) {
  54. days.forEach(function(el, j, days) {
  55. if (el === item.from.split(' ')[0]) {
  56. dayk = (el - 1);
  57. }
  58. });
  59. k = 24 + k;
  60. }
  61. if (l < 0) {
  62. days.forEach(function(el, j, days) {
  63. if (el === item.to.split(' ')[0]) {
  64. dayl = (el - 1);
  65. }
  66. });
  67. l = 24 + l;
  68. }
  69. m = String(k);
  70. n = String(l);
  71. if (m.length < 2) {
  72. res.push(dayk + '0' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
  73. }
  74. else if (n.length < 2) {
  75. res.push(dayk + ' ' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + '0' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
  76. } else {
  77. res.push(dayk + ' ' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
  78. }
  79. });
  80. }
  81.  
  82. return res;
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement