Solution to count back a year in 6.x and 5.x
caomhin - January 1, 2009 - 09:26
| Project: | Archive |
| Version: | HEAD |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Description
This morning I was greeted by an error saying there was an incorrect date on line 106. The following change appears to work:
if($month==1) {
$num_days_prev = cal_days_in_month(CAL_GREGORIAN, 12, $prev_year);
} else {
$num_days_prev = cal_days_in_month(CAL_GREGORIAN, $month-1, $year); // orig code
}
#1
same same:
warning: cal_days_in_month() [function.cal-days-in-month]: invalid date. in /homez.59/my_DB_name/www/sites/all/modules/archive/archive.module on line 106.I've tried to replace line 106 by your code:
#2
Same issue here but the code appeared to fix the problem.
Thanks.
#3
I used your solution with version 5.14 and fixed the warning of cal_days_in_month,,
I just removed the comment in the original code line because leaving it causes a Parse error;
so, my final code is like this:
if($month==1) {$num_days_prev = cal_days_in_month(CAL_GREGORIAN, 12, $prev_year);
} else {
$num_days_prev = cal_days_in_month(CAL_GREGORIAN, $month-1, $year);
}
#4
just fixing the forum title to a better search :)
#5
just fixing the forum title to a better search :)
#6
Same error here on latest 5.x Drupal core and latest version of this module.
Made the change indicated above by hand, and the errors have cleared.
#7
The fix is also a possible solution to the same problem with drupal 6.8.
#8
A better patch for the 6.x one at least (I don't have 5.x to test with):
// OLD: $num_days_prev = cal_days_in_month(CAL_GREGORIAN, $month-1, $year);$num_days_prev = cal_days_in_month(CAL_GREGORIAN, $prev_month, $prev_year);
It only requires the one line because the current version of the 6.x branch already works out what last month was and what year it was in and assigns it to the prev_month and prev_year variables.
#9
i tested it on 5.x and it doesn't work for me.(#8)
the other patch is perfect.(#3)
thanks all!
#10
Hello,
I had the same issue but solved now. I tried the mdin617's patch (Drupal 6 too) and it worked perfectly.
Thank you very much!
#11
same issue here:
cal_days_in_month() [function.cal-days-in-month]: invalid date. in sites/all/modules/archive/archive.module line 359.
PHP version is 5.2.6-5, Drupal core 5.14, archive module 5.x-1.11.
solution #3 by sietecoyote worked fine, patch file is attached.
#12
This is more correct fix:
$num_days_prev = cal_days_in_month(CAL_GREGORIAN, $prev_month, $prev_year);#13
according to #9, this one-liner doesn't work on Drupal 5.