addMarkedTimespan not working when specifying specific date

Hi everyone,

I’m using addMarkedTimespan to block off times in the calendar, and it works great when using 0-6 for recurring blocks, but when I want to block specific known dates, it doesn’t work. For example:

scheduler.addMarkedTimespan({days: 0, zones: "fullday", css: "gray_section", type: "dhx_time_block"});

Works fine.

scheduler.addMarkedTimespan({days:new Date(2014,6,21), zones: "fullday", css: "gray_section", type: "dhx_time_block"});

Does nothing, but doesn’t throw an error. I’ve also tried blockTime, and it does the same thing.

I looked at this sample: … ation.html

And in the source, it shows this:

// we can block specific dates scheduler.blockTime(new Date(2009,5,30), "fullday"); scheduler.blockTime(new Date(2009,6,3), [0,10*60]);

But even those dates aren’t blocked in the demo! Is this feature broken, or is there a way to block specific dates?


Not sure what do you mean, dates seems to be blocked:

Can you clarify?

That’s May 30, not June 30. :wink:

JavaScript month are zero-based, 0 is for January, 11 for December,
so following date object means 30th June

new Date(2009,5,30)

Wow! So I can just subtract one from each month and totally fix my problem?

That definitely fixed it. I don’t have a lot of experience with Javascript. Isn’t it kind of dumb that it uses 0 as the base for month, but not day?

Another similar question. When specifying zones, do I approach it as “this hour plus this many minutes”?

Like to do a zone of 8am-11:30am, would it be 760,1130?


to get marked 8:00am - 11:30am you can use any configuration in minutes:

zones: [16*30, 23*30], or zones: [8*60, 23*30], or zones: [8*60, 11*60+30]

more precisely, zones are specifying time intervals within a day. Each interval is defined by pair (i, i+1) of values of an arrayzones:[interval1_start, interval1_end, interval2_start, interval2_end, ...] zones:[interval1_start, interval1_end, interval2_start, interval2_end]
Time values are specified as minutes since midnight (e.g. 60 for 1am, 150 for 2:30am). It may became not readable if you specify full values, so usually it is written as a composition of hour and minute part:zones:[8*60, 11*60 + 30];//8:00am - 11:30am zones:[8*60, 11*60 + 30, 12*60 + 30, 18*60]//8:00am - 11:30am and 12:30pm-6:00pm

Ah, that explains it! Makes perfect sense now. So all of the x*60 stuff I’ve been seeing in the documentation is just to make it easier to read, and javascript “does the math” when it loads the page. If I’m retrieving these zones from php, I may as well go ahead and represent the zones in minutes, and save myself a thousandth of a second or whatever it takes to do basic multiplication!

Thanks for the quick responses.