|
|
@ -10,42 +10,6 @@ var moment = require('../module/moment'); |
|
|
|
* @param Core |
|
|
|
*/ |
|
|
|
exports.convertHiddenOptions = function(body, hiddenDates) { |
|
|
|
//var specificHiddenDates = hiddenDates.specific;
|
|
|
|
//if (specificHiddenDates) {
|
|
|
|
// if (Array.isArray(specificHiddenDates) == true) {
|
|
|
|
// for (var i = 0; i < specificHiddenDates.length; i++) {
|
|
|
|
// var dateItem = {};
|
|
|
|
// dateItem.start = moment(specificHiddenDates[i].start).toDate().valueOf();
|
|
|
|
// dateItem.end = moment(specificHiddenDates[i].end).toDate().valueOf();
|
|
|
|
// body.hiddenDates.push(dateItem);
|
|
|
|
// }
|
|
|
|
// body.hiddenDates.sort(function (a, b) {
|
|
|
|
// return a.start - b.start;
|
|
|
|
// }); // sort by start time
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// body.hiddenDates = [{
|
|
|
|
// start: moment(specificHiddenDates.start).toDate().valueOf(),
|
|
|
|
// end: moment(specificHiddenDates.end).toDate().valueOf()
|
|
|
|
// }
|
|
|
|
// ];
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//// allowing multiple input formats
|
|
|
|
//var periodicHiddenDates = hiddenDates.periodic;
|
|
|
|
//if (periodicHiddenDates) {
|
|
|
|
// if (periodicHiddenDates.times) {
|
|
|
|
// if (Array.isArray(periodicHiddenDates.times) != true) {
|
|
|
|
// periodicHiddenDates.times = [periodicHiddenDates.times];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (periodicHiddenDates.days) {
|
|
|
|
// if (Array.isArray(periodicHiddenDates.days) != true) {
|
|
|
|
// periodicHiddenDates.days = [periodicHiddenDates.days];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
body.hiddenDates = []; |
|
|
|
if (hiddenDates) { |
|
|
|
if (Array.isArray(hiddenDates) == true) { |
|
|
@ -94,25 +58,25 @@ exports.updateHiddenDates = function (body, hiddenDates) { |
|
|
|
if (startDate.day() != endDate.day()) { |
|
|
|
offset = 1; |
|
|
|
} |
|
|
|
startDate.day(start.day); |
|
|
|
startDate.subtract(7,'days'); |
|
|
|
startDate.month(start.month()); |
|
|
|
startDate.dayOfYear(start.dayOfYear()); |
|
|
|
startDate.year(start.year()); |
|
|
|
startDate.subtract(7,'days'); |
|
|
|
|
|
|
|
endDate.day(start.day); |
|
|
|
endDate.subtract(7 + offset,'days'); |
|
|
|
endDate.month(start.month()); |
|
|
|
endDate.dayOfYear(start.dayOfYear()); |
|
|
|
endDate.year(start.year()); |
|
|
|
endDate.subtract(7,'days'); |
|
|
|
endDate.add(offset,'days'); |
|
|
|
break; |
|
|
|
case "weekly": |
|
|
|
if (startDate.week() != endDate.week()) { |
|
|
|
offset = 1; |
|
|
|
} |
|
|
|
startDate.week(start.week() - 1) |
|
|
|
startDate.week(start.week() - 1); |
|
|
|
startDate.year(start.year()); |
|
|
|
|
|
|
|
endDate.week(start.week() - 1 + offset) |
|
|
|
endDate.week(start.week() - 1); |
|
|
|
endDate.year(start.year()); |
|
|
|
endDate.add(offset,'weeks'); |
|
|
|
break |
|
|
|
case "monthly": |
|
|
|
if (startDate.month() != endDate.month()) { |
|
|
@ -121,16 +85,17 @@ exports.updateHiddenDates = function (body, hiddenDates) { |
|
|
|
startDate.month(start.month() - 1) |
|
|
|
startDate.year(start.year()); |
|
|
|
|
|
|
|
endDate.month(start.month() - 1 + offset) |
|
|
|
endDate.month(start.month() - 1); |
|
|
|
endDate.year(start.year()); |
|
|
|
endDate.add(offset,'months'); |
|
|
|
break; |
|
|
|
case "yearly": |
|
|
|
if (startDate.year() != endDate.year()) { |
|
|
|
offset = 1; |
|
|
|
} |
|
|
|
startDate.year(start.year() - 1); |
|
|
|
|
|
|
|
endDate.year(start.year() - 1 + offset); |
|
|
|
endDate.year(start.year() - 1); |
|
|
|
endDate.add(offset,'years'); |
|
|
|
break; |
|
|
|
default: |
|
|
|
console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", hiddenDates[i].repeat); |
|
|
|