Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,239
When I launch my code I get the "ERROR: Cannot read property 'getFullYear' of undefined"
I've managed to track it down:
Which writes out:
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) Wed Mar 02 2016 00:00:00 GMT+0100 (Västeuropa, normaltid)
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) Wed Mar 02 2016 00:00:00 GMT+0100 (Västeuropa, normaltid)
pre crash
So the issue is the !this.inTimerFilter()
Which writes:
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) undefined
What. It was fine just before calling the method.
I've managed to track it down:
Code:
if (!isNaN(Date.parse(finishedD)) && finishedD !== undefined){ //I even filter out undefined here, but that did not help as you see.
_finishedDate = finishedD;
console.log(this.dueDate + ' ' + finishedD);
console.log(this.dueDate + ' ' + _finishedDate);
_isDone = true;
console.log('pre crash');
if (!this.inTimeFilter()) {
_isOverdue = true;
}
console.log('aftermath');
}
Which writes out:
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) Wed Mar 02 2016 00:00:00 GMT+0100 (Västeuropa, normaltid)
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) Wed Mar 02 2016 00:00:00 GMT+0100 (Västeuropa, normaltid)
pre crash
So the issue is the !this.inTimerFilter()
Code:
inTimeFilter() {
console.log(this.dueDate + ' ' + this.finishedDate);
return this.finishedDate.getFullYear() <= this.dueDate.getFullYear() &&
this.finishedDate.getMonth() <= this.dueDate.getMonth() &&
this.finishedDate.getDate() <= this.dueDate.getDate();
}
Thu Dec 31 2015 00:00:00 GMT+0100 (Västeuropa, normaltid) undefined
What. It was fine just before calling the method.