Hello,

I recently installed 'Calendar Block' but when I enabled the block, I am getting this error, "Fatal error: Call to undefined function cal_days_in_month() in /home/user/epoly/public_html/sites/all/modules/calendar_block/calendar_block.module on line 151" Am I doing something really stupid? Thanks in advance.

Aniruddha

CommentFileSizeAuthor
#6 cal_days_in_month.patch991 bytesjmstacey

Comments

skilip’s picture

cal_days_in_month() is a PHP function (PHP 4.07 and greater). Which version of PHP do you have?

aniruddhay’s picture

Hello,

sorry for the late reply. I am running PHP 5.2.6, does this help?

thanks,
Aniruddha

aniruddhay’s picture

Hello,

sorry for the late reply. I am running PHP 5.2.6, does this help?

thanks,
Aniruddha

Dhaishin’s picture

I too have suffered from this error, though I am using PHP 5.0.4. I currently re-compiling PHP to add the mbstring extension... I don't see this as helping, but who knows...

Andrew

skilip’s picture

You need to be sure the extension 'calendar' is compiled. See documentation at php.net

jmstacey’s picture

Status: Active » Needs review
StatusFileSize
new991 bytes

Here's a patch that adds a replacement for the cal_days_in_month() function if you're using a version of PHP that does not have it. The file is not using Unix line endings so I don't know if the patch will work properly. Just in case here is the new function, just put it somewhere in your calendar_block.module file. I got the solution from http://drupal.org/node/310120

/**
 * Calendar days in month
 *
 * Some PHP versions don't have cal_days_in_month(), this accounts for that.
 */

if(!function_exists('cal_days_in_month')){
	
	function cal_days_in_month($calendar,$month, $year) {
		// $calendar just gets ignored, assume gregorian
		// calculate number of days in a month
		return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
	}
	 
}
skilip’s picture

Thanks a lot jmstacey!

I've taken your code into a new release.

skilip’s picture

Status: Needs review » Fixed
aniruddhay’s picture

I couldn't thank you enough. :) And thanks a lot skilip too. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.