I am looking for the best way to handle Dates & Times on my SpineJS models. I am working on creating an event calendar of sorts. The first hurdle being to display a nice 6 week calendar. It must start on the last Sunday of the previous month, ending on the first Saturday of the next month.
I was using DateJs (http://www.datejs.com/) and handling some date things in the View template but wanted to move some of this to a model to cleanup said view.
The function I am working on is called 'firstDay'. This will find the date where we start our calendar (the last Sunday of the previous month)
firstDay: () ->
Date.today().set({month: @month}).moveToFirstDayOfMonth().moveToDayOfWeek(0, -1)
My attempted usage:
<% day = cal.firstDay %>
// initialize the table header, etc
<tbody>
<% while !day.equals(cal.lastDay): %>
// render each calendar tile/square
And here is the error:
Uncaught TypeError: Object function () {
return Date.today().set({
month: this.month
}).moveToFirstDayOfMonth().moveToDayOfWeek(0, -1);
} has no method 'equals'
So my Spine model appears to be unaware of DateJS... I guess that makes sense. It looks like the function itself is being returned, not the evaluation of the function... if that makes sense.
Any guidance here would be appreciated on the best way to incorporate dates and times into my models.
thanks