Reputation: 475
I'm using the Trigger calendar module, however when calling the following code in iOS it just stops the app without any reaction -- the problem does not occur on Android, however there the dates seem to not be correctly entered in the calendar:
var start = new Date(this.booking.startdatetime());
var end = new Date(this.booking.enddatetime());
forge.calendar.addEvent({
title:"title",
description:"description",
start:start,
end:end,
allday:false
}, function () {
alert("Event added!");
}, function (content) {
alert("error");
}
);
The callbacks are never reached, also trying to catch any exceptions does not give a result. However, it works perfectly when just passing new Date()
as start/end it works.
My own start/date variables have the format:
Sun Feb 03 2013 22:00:00 GMT+0100 (Mitteleuropäische Zeit)
It looks the same as new Date()
, anyhow I guess that's where the problem is?
Upvotes: 1
Views: 98
Reputation: 475
The problem came from one of my date strings being not properly formatted -- Found this out by going back to web mode and examining the objects in Chrome...
Anyway, after some more trouble on that side I now need to format my dates like that:
var start = moment(this.booking.startdatetime(), "YYYY-MM-DD HH-mm-ss").toDate();
var end = moment(this.booking.enddatetime(), "YYYY-MM-DD HH-mm-ss").toDate();
Doing this it works generally -- only problem is that now, when calling the calendar, it adds or substracts one to two minutes from the date object sometimes. Randomly as it seems.
Logging tells me that the dates are still correct right before the addEvent()
call -- any suggestions on why this happens or how to debug it?
Upvotes: 2