wasimshaikh / php-calendar

Automatically exported from code.google.com/p/php-calendar
1 stars 0 forks source link

"Month is out of range" error message #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Click on December to display month on screen.
2. Click Next Month (should ideally go to January of the following year)
3. Get Software error message:
Month is out of range
Backtrace
/var/www/staffcalendar/includes/setup.php:91 - display_error 
/var/www/staffcalendar/index.php:63 - require_once 

What is the expected output? What do you see instead?
I expect to see January of the following year, if I click "Next Month" when 
viewing December and I expect to December of the previous year if I click 
"Previous Month" when viewing january. Instead I get the following software 
error message on screen:
"Month is out of range
"Backtrace
"/var/www/staffcalendar/includes/setup.php:91 - display_error 
"/var/www/staffcalendar/index.php:63 - require_once 

What version of the product are you using? On what operating system?
Version2 Beta 8

Please provide any additional information below.

I hope this can be solved! Thanks for the calendar and your work.

Original issue reported on code.google.com by awon...@gmail.com on 15 Sep 2010 at 11:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I fixed that by putting an if() statement in function month_navbar() in 
path_to_includes/display_month.php . 
I just changed it so if January is currently displayed then the link for "last 
month" will point to the December of the previous year.  If December is 
currently displayed then the link for "next month" points to January of the 
next year.

The altered function:

function month_navbar($month, $year)
{
    $html = tag('div', attributes('class="phpc-month-nav"'));
    menu_item_append_with_date($html, _('last year'), 'display_month',
            $year - 1, $month);

    if ($month==1){     
        menu_item_append_with_date($html, _('last month'), 'display_month',
            $year -1, 12);
    }else{
        menu_item_append_with_date($html, _('last month'), 'display_month',
            $year, $month - 1);
    }

    for($i = 1; $i <= 12; $i++) {
        if($i < $month)
            $attribs = 'class="phpc-past"';
        elseif($i == $month)
            $attribs = 'class="phpc-present"';
        else
            $attribs = 'class="phpc-future"';

        menu_item_append_with_date($html, short_month_name($i),
                'display_month', $year, $i, false, $attribs);
    }

    if ($month==12){        
        menu_item_append_with_date($html, _('next month'), 'display_month',
            $year +1, 1);
    }else{
        menu_item_append_with_date($html, _('next month'), 'display_month',
            $year, $month + 1);
    }

    menu_item_append_with_date($html, _('next year'), 'display_month',
            $year + 1, $month);

    return $html;
}

-G

Original comment by 5forceg...@gmail.com on 15 Sep 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Thank you for that code. I have added it and have solved the problem.

Original comment by awon...@gmail.com on 16 Sep 2010 at 3:32

GoogleCodeExporter commented 9 years ago
This is fixed in r460. Sorry, I should've released an updated version early as 
this is a pretty visible issue.

Original comment by sproctor@gmail.com on 19 Oct 2010 at 3:58