Skip to content

Commit

Permalink
Merge pull request #85 from nldn/master
Browse files Browse the repository at this point in the history
Fix wrong date
  • Loading branch information
hariszupcevic authored Mar 4, 2020
2 parents 991f6ce + c39e773 commit 450a703
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions widget/controllers/widget.event.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@
/*Add to calendar event will add here*/
var eventStartDate = new Date(event.data.startDate);
var eventEndDate;
if (event.data.endDate !== '' && event.data.endDate < event.data.startDate) {
if (event.data.endDate !== '' && event.data.endDate > event.data.startDate) {
eventEndDate = new Date(event.data.endDate);
}
else {
eventEndDate = new Date(event.data.startDate + 3600); //add hour to start date to derive end date
eventEndDate = new Date(event.data.startDate + 3600000); //add hour to start date to derive end date
}
if (WidgetEvent.getAddedEventToLocalStorage(event.id) != -1) {
alert("Event already added in calendar");
Expand All @@ -171,6 +171,7 @@
}
if (event.data.description) {
eventDescr = event.data.description.replace(/<[^>]*>?/g, ''); //dépouiller les caractères spéciaux
eventDescr = decodeHtmlCharCodes(eventDescr);
} else {
eventDescr = "";
}
Expand All @@ -188,6 +189,13 @@
}
}
}

function decodeHtmlCharCodes(str) {
return str.replace(/(&#(\d+);)/g, function(match, capture, charCode) {
return String.fromCharCode(charCode);
});
};

buildfire.device.calendar.addEvent(
{
title: eventTitle
Expand Down

0 comments on commit 450a703

Please sign in to comment.