Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.5

Bug #17182 Calendar/Month/Weeks.php bug
Submitted: 2010-03-02 05:49 UTC
From: kenji Assigned: quipo
Status: Closed Package: Calendar (version 0.5.4)
PHP Version: 5.3.0 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2010-03-02 05:49 UTC] kenji (Kenji Suzuki)
Description: ------------ Calendar/Month/Weeks.php generates wrong Calendar in 2010. 0.5.3 generates correct calendar. This bug seems to be caused by Week.php thisYear() function. Test script: --------------- <?php require_once 'Calendar/Month/Weeks.php'; $weekdayDefines = array(array('Su', 'sunday'), array('Mo', 'monday'), array('Tu', 'tuesday'), array('We', 'wednesday'), array('Th', 'thursday'), array('Fr', 'friday'), array('Sa', 'saturday')); $weekdayBase = 0; $year = (int) date('Y'); $month = (int) date('n'); if (isset($_GET['year_month'])) { $yyyymm = trim($_GET['year_month']); if (preg_match('/^([12]\d{3})(1[012]|0[1-9])$/', $yyyymm, $match)) { $year = (int) $match[1]; $month = (int) $match[2]; } } $calendar = new Calendar_Month_Weeks($year, $month, $weekdayBase); $calendar->build(); $thisMonth = $calendar->thisMonth(TRUE); $prevMonth = $calendar->prevMonth(TRUE); $nextMonth = $calendar->nextMonth(TRUE); $prevMonthUrl = '?year_month=' . date('Ym', $prevMonth); $nextMonthUrl = '?year_month=' . date('Ym', $nextMonth); $thisMonthText = date('Y/m', $thisMonth); ?> <table border="1"> <thead> <tr> <td><a href="<?php echo $prevMonthUrl;?>"><<</a></td> <th colspan="5"><?php echo $thisMonthText;?></th> <td><a href="<?php echo $nextMonthUrl;?>">>></a></td> </tr> <tr> <?php for ($i = 0; $i < 7; $i++) { $weekday = ($weekdayBase + $i) % 7; $weekdayText = $weekdayDefines[$weekday][0]; $weekdayClass = $weekdayDefines[$weekday][1]; echo '<th class="' . $weekdayClass . '">', $weekdayText, '</th>'; } ?> </tr> </thead> <tbody> <?php while ($days = $calendar->fetch()) { $days->build(); $weekday = 0; echo '<tr>'; while ($day = $days->fetch()) { $weekdayClass = $weekdayDefines[$weekday][1]; if ($day->isEmpty()) { $dayText = " "; } else { $dayText = $day->thisDay(); } echo '<td class="' . $weekdayClass . '">', $dayText, '</td>'; $weekday++; } echo '</tr>'; } ?> </tbody> </table> Expected result: ---------------- << 2010/03 >> Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Actual result: -------------- << 2010/03 >> Su Mo Tu We Th Fr Sa 28 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Comments

 [2010-03-11 15:42 UTC] deepz0ne (John Smith)
I can confirm this. Also: when used with ...while ($Day = $Week->fetch()) {... $Day->isEmpty(); gives empty days for march 2010 1/7
 [2010-06-23 16:32 UTC] ulope (Ulrich Petri)
I can also confirm. Calendar_Month_Weeks' empty day handling seems really borked in 2010.
 [2010-06-24 16:36 UTC] quipo (Lorenzo Alberton)
-Status: Open +Status: Closed -Assigned To: +Assigned To: quipo
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.