svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/calendar/calendar.c branches/PHP_5_3/ext/calendar/tests/bug52744.phpt
trunk/ext/calendar/calendar.c trunk/ext/calendar/tests/bug52744.phpt
| From: | Adam Harvey | Date: | Thu, 09 Sep 2010 06:41:23 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/calendar/calendar.c branches/PHP_5_3/ext/calendar/tests/bug52744.phpt trunk/ext/calendar/calendar.c trunk/ext/calendar/tests/bug52744.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63458@lists.php.net to get a copy of this message | ||
aharvey Thu, 09 Sep 2010 06:41:23 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303203
Log:
Fixed bug #52744 (cal_days_in_month incorrect for December 1 BCE). Original
patch by gpap at internet dot gr.
Bug: http://bugs.php.net/52744 (Assigned) cal_days_in_month
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/calendar/calendar.c
A php/php-src/branches/PHP_5_3/ext/calendar/tests/bug52744.phpt
U php/php-src/trunk/ext/calendar/calendar.c
A php/php-src/trunk/ext/calendar/tests/bug52744.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-09-09 05:45:41 UTC (rev 303202)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-09-09 06:41:23 UTC (rev 303203)
@@ -20,6 +20,8 @@
- Fixed bug #52786 (PHP should reset section to [PHP] after ini sections).
(Fedora at famillecollet dot com)
+- Fixed bug #52744 (cal_days_in_month incorrect for December 1 BCE).
+ (gpap at internet dot gr, Adam)
- Fixed bug #52725 (gcc builtin atomic functions were sometimes used when they
were not available). (fat)
- Fixed bug #52745 (Binding params doesn't work when selecting a date inside a
Modified: php/php-src/branches/PHP_5_3/ext/calendar/calendar.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/calendar/calendar.c 2010-09-09 05:45:41 UTC (rev 303202)
+++ php/php-src/branches/PHP_5_3/ext/calendar/calendar.c 2010-09-09 06:41:23 UTC (rev 303203)
@@ -348,8 +348,15 @@
sdn_next = calendar->to_jd(year, 1 + month, 1);
if (sdn_next == 0) {
-/* if invalid, try first month of the next year... */
- sdn_next = calendar->to_jd(year + 1, 1, 1);
+ /* If the next month is invalid, then we need to try the first month of
+ * the next year, bearing in mind that the next year after 1 BCE is
+ * actually 1 AD and not 0. */
+ if (year == -1) {
+ sdn_next = calendar->to_jd(1, 1, 1);
+ }
+ else {
+ sdn_next = calendar->to_jd(year + 1, 1, 1);
+ }
}
RETURN_LONG(sdn_next - sdn_start);
Added: php/php-src/branches/PHP_5_3/ext/calendar/tests/bug52744.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/calendar/tests/bug52744.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/calendar/tests/bug52744.phpt 2010-09-09 06:41:23 UTC (rev
303203)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52744 (cal_days_in_month incorrect for December 1 BCE)
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+var_dump(cal_days_in_month(CAL_GREGORIAN, 12, -1));
+var_dump(cal_days_in_month(CAL_JULIAN, 12, -1));
+?>
+--EXPECT--
+int(31)
+int(31)
Modified: php/php-src/trunk/ext/calendar/calendar.c
===================================================================
--- php/php-src/trunk/ext/calendar/calendar.c 2010-09-09 05:45:41 UTC (rev 303202)
+++ php/php-src/trunk/ext/calendar/calendar.c 2010-09-09 06:41:23 UTC (rev 303203)
@@ -348,8 +348,15 @@
sdn_next = calendar->to_jd(year, 1 + month, 1);
if (sdn_next == 0) {
-/* if invalid, try first month of the next year... */
- sdn_next = calendar->to_jd(year + 1, 1, 1);
+ /* If the next month is invalid, then we need to try the first month of
+ * the next year, bearing in mind that the next year after 1 BCE is
+ * actually 1 AD and not 0. */
+ if (year == -1) {
+ sdn_next = calendar->to_jd(1, 1, 1);
+ }
+ else {
+ sdn_next = calendar->to_jd(year + 1, 1, 1);
+ }
}
RETURN_LONG(sdn_next - sdn_start);
Added: php/php-src/trunk/ext/calendar/tests/bug52744.phpt
===================================================================
--- php/php-src/trunk/ext/calendar/tests/bug52744.phpt (rev 0)
+++ php/php-src/trunk/ext/calendar/tests/bug52744.phpt 2010-09-09 06:41:23 UTC (rev 303203)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52744 (cal_days_in_month incorrect for December 1 BCE)
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+var_dump(cal_days_in_month(CAL_GREGORIAN, 12, -1));
+var_dump(cal_days_in_month(CAL_JULIAN, 12, -1));
+?>
+--EXPECT--
+int(31)
+int(31)