Weeknumber

Hello,

Is it possible to display the weeknumber in the dhx_cal_date div?

Regards,
Michiel Klaver

You can redefine template for related area, and use any custom logic for text generation.
Unfortunately, current version of scheduler can’t calculate week number from the date automatically.

Hello,

Thanks for you reply, is it also possible to display the current date in another div outside the scheduler container? The same date that is displayed in the dhx_cal_date div?

Best Regards,
Michiel KLaver

Hey guys,
i wrote this little function to calculate the calendar week. I´m using the definition of the ISO 8601, where the week with the 4.January of a year is the first calender week.

[code]function sm_calenderweek(date)
{
var year = date.getYear();
var fourthJan = new Date(year,00,04);
var calweek = date-fourthJan;
calweek= calweek/(2460601000);
if(fourthJan.getDay()!=0)calweek = calweek + fourthJan.getDay()-1;
else calweek = calweek+1;
calweek = (calweek /7 )+1;
calweek = Math.ceil(calweek);
if(calweek == 53)
{
fourthJan = new Date(year+1,00,04);
if((fourthJan-date)/(24
60601000)<=4){
calweek=1;
}

}
return calweek;

[/code]

to show this in weekview u need to implement:

scheduler.templates.week_date=function(date){ var string = 'KW '+ sm_calenderweek(date) + ', ' + date.getYear(); return string; }
or something like that

Hello,

This function isn’t really working at me, if I go to monday 4 januari 2010, I get weeknumber 99139?
But thanks for the help.

Regards,
Michiel Klaver

Hello,

I wrote my own function and this is working correctly:

function getIso8601Week(date) {
				var checkDate = new Date(date.getTime());
				checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
				var time = checkDate.getTime();
				checkDate.setMonth(0);
				checkDate.setDate(1);
				return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
			}

Why not useing Boars search?
Complete function could be found here:

http://forum.dhtmlx.com/viewtopic.php?f=6&t=12404&p=35723#p35723