Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var schedule = {
- Danny: [
- { from: 'ПН 12:00+5', to: 'ПН 17:00+5' },
- { from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
- ],
- Rusty: [
- { from: 'ПН 11:30+5', to: 'ПН 16:30+5' },
- { from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
- ],
- Linus: [
- { from: 'ПН 00:00+3', to: 'ПН 14:00+3' },
- { from: 'ПН 21:00+3', to: 'ВТ 09:30+3' },
- { from: 'СР 09:30+3', to: 'СР 15:00+3' }
- ]
- };
- var bankHours = {
- from: '10:00+2',
- to: '18:00+2'
- };
- function Nowdays(schedule, workingHours) {
- var time = parse_(schedule, workingHours);
- var time_news = {
- mon : [],
- tue : [],
- wes : [],
- };
- var time_newe = [];
- time.forEach(function(item, i, time) {
- item.forEach(function(elem, j, item) {
- time_news.push(new Date(2016, 9, 17, elem.split('to')[0].split(' ')[1].split(':')[0], elem.split('to')[0].split(' ')[1].split(':')[1]));
- time_newe.push(new Date(2016, 9, 17, elem.split('to')[1].split(' ')[1].split(':')[0], elem.split('to')[1].split(' ')[1].split(':')[1]));
- });
- time_news.push('next');
- time_newe.push('next');
- });
- return [time_news, time_newe];
- }
- function lol(schedule, bankHours, arr) {
- var hourL = schedule.Linus[0].from.split('+')[1];
- var hourB = bankHours.from.split('+')[1];
- var arr = schedule.Linus;
- var res = [];
- var days = ["ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС", "ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС", "ПН"];
- if (hourL != hourB) {
- arr.forEach(function(item, i, arr) {
- k = Number(item.from.split(' ')[1].split(':')[0]) + (Number(hourB) - Number(hourL));
- l = Number(item.to.split(' ')[1].split(':')[0]) + (Number(hourB) - Number(hourL));
- dayk = item.from.split(' ')[0];
- dayl = item.to.split(' ')[0];
- if (k < 0) {
- days.forEach(function(el, j, days) {
- if (el === item.from.split(' ')[0]) {
- dayk = (el - 1);
- }
- });
- k = 24 + k;
- }
- if (l < 0) {
- days.forEach(function(el, j, days) {
- if (el === item.to.split(' ')[0]) {
- dayl = (el - 1);
- }
- });
- l = 24 + l;
- }
- m = String(k);
- n = String(l);
- if (m.length < 2) {
- res.push(dayk + '0' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
- }
- else if (n.length < 2) {
- res.push(dayk + ' ' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + '0' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
- } else {
- res.push(dayk + ' ' + m + ':' + item.from.split(' ')[1].split(':')[1].split('+')[0] + 'to' + dayl + ' ' + n + ':' + item.to.split(' ')[1].split(':')[1].split('+')[0]);
- }
- });
- }
- return res;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement