Removes the 'Z' from the UNTIL before sending the rrule to the API

This commit is contained in:
Jared Tabor 2018-05-07 14:41:22 -07:00
parent 33d4c97156
commit 876431c529

View File

@ -1,5 +1,21 @@
export default
function RRuleToAPI() {
// This function removes the 'Z' from the UNTIL portion of the
// rrule. The API will default to using the timezone that is
// specified in the TZID as the locale for the UNTIL.
function parseOutZ (rrule) {
let until = rrule.split('UNTIL=');
if(_.has(until, '1')){
rrule = until[0];
until = until[1].replace('Z', '');
return `${rrule}UNTIL=${until}`;
} else {
return rrule;
}
}
return function(rrule, scope) {
let localTime = scope.schedulerLocalTime;
let timeZone = scope.schedulerTimeZone.name;
@ -7,6 +23,8 @@ export default
let response = rrule.replace(/(^.*(?=DTSTART))(DTSTART.*?)(=.*?;)(.*$)/, (str, p1, p2, p3, p4) => {
return p2 + ';TZID=' + timeZone + ':' + localTime + ' ' + 'RRULE:' + p4;
});
response = parseOutZ(response);
return response;
};
}