themouette / jquery-week-calendar

A weekly calendar plugin based on jquery and jquery-ui
http://groups.google.com/group/jquery-week-calendar
720 stars 253 forks source link

"dateTime.getTime is not a function" using freebusys option in JSON data #170

Open grimgit opened 11 years ago

grimgit commented 11 years ago

events.json

{
  events: [ ... ],
  freebusys: [
    {"start":"2013-03-11T08:10:00+01:00","end":"2013-03-11T10:00:00+01:00","free":true},
    ...
  ]
}

weekCalendar init

  ...
  $calendar.weekCalendar('option', 'data', 'events.json');
  $calendar.weekCalendar('refresh');

This example rise "dateTime.getTime is not a function" javascript error. I haven't found the exact reason, but with this use case the functions freebusy.getStart() and freebusy.getEnd() don't return a Date object.

Quick fix, change this:

      getStart: function() {return this.getOption('start')},
      getEnd: function() {return this.getOption('end')},

with this:

      getStart: function() {return new Date(this.getOption('start'))},
      getEnd: function() {return new Date(this.getOption('end'))},

This is just a quick fix, we have to find why freebusy start and end aren't date objects.