]> granicus.if.org Git - php/commitdiff
- MFH: Fixed a bug that caused miscalculations with the "last <weekday> of <n>
authorDerick Rethans <derick@php.net>
Tue, 5 Aug 2008 18:03:47 +0000 (18:03 +0000)
committerDerick Rethans <derick@php.net>
Tue, 5 Aug 2008 18:03:47 +0000 (18:03 +0000)
  month" relative time string.

NEWS
ext/date/lib/tm2unixtime.c
ext/date/tests/date_period.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 671ce91fbde933ecb74880351757dd2e0382db56..e8b009a573721a1aa8d9d611935da066a286e8fa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 200?, PHP 5.3.0 Alpha 2
 - Removed shebang line check from CGI sapi (it is checked by scanner) (Dmitry)
+- Fixed a bug that caused miscalculations with the "last <weekday> of <n>
+  month" relative time string. (Derick)
 
 - Fixed bug #45696 (Not all DateTime methods allow method chaining). (Derick)
 - Fixed bug #45545 (DateInterval has a limitation of 4 chars for ISO
index 458baca0abe1889ba6e55c8afdc9d094545361fa..1ba4439d04db9dc9d6bb612ada83d6b100f1e9db 100644 (file)
@@ -277,6 +277,7 @@ static void do_adjust_special_early(timelib_time* time)
                                break;
                }
        }
+       do_normalize(time);
 }
 
 static timelib_sll do_years(timelib_sll year)
diff --git a/ext/date/tests/date_period.phpt b/ext/date/tests/date_period.phpt
new file mode 100644 (file)
index 0000000..65dd1b1
--- /dev/null
@@ -0,0 +1,64 @@
+--TEST--
+DatePeriod
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$db = new DateTime( '2008-01-01' );
+$de = new DateTime( '2008-12-31' );
+$di = DateInterval::createFromDateString( 'first day of next month' );
+
+foreach ( new DatePeriod( $db, $di, $de ) as $dt )
+{
+    echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" );
+}
+?>
+
+<?php
+$db = new DateTime( '2007-12-31' );
+$de = new DateTime( '2009-12-31 23:59:59' );
+$di = DateInterval::createFromDateString( 'last thursday of next month' );
+
+foreach ( new DatePeriod( $db, $di, $de, DatePeriod::EXCLUDE_START_DATE ) as $dt )
+{
+    echo $dt->format( "l Y-m-d H:i:s\n" );
+}
+?>
+--EXPECT--
+Tuesday 2008-01-15
+Tuesday 2008-02-19
+Tuesday 2008-03-18
+Tuesday 2008-04-15
+Tuesday 2008-05-20
+Tuesday 2008-06-17
+Tuesday 2008-07-15
+Tuesday 2008-08-19
+Tuesday 2008-09-16
+Tuesday 2008-10-21
+Tuesday 2008-11-18
+Tuesday 2008-12-16
+
+Thursday 2008-01-31 00:00:00
+Thursday 2008-02-28 00:00:00
+Thursday 2008-03-27 00:00:00
+Thursday 2008-04-24 00:00:00
+Thursday 2008-05-29 00:00:00
+Thursday 2008-06-26 00:00:00
+Thursday 2008-07-31 00:00:00
+Thursday 2008-08-28 00:00:00
+Thursday 2008-09-25 00:00:00
+Thursday 2008-10-30 00:00:00
+Thursday 2008-11-27 00:00:00
+Thursday 2008-12-25 00:00:00
+Thursday 2009-01-29 00:00:00
+Thursday 2009-02-26 00:00:00
+Thursday 2009-03-26 00:00:00
+Thursday 2009-04-30 00:00:00
+Thursday 2009-05-28 00:00:00
+Thursday 2009-06-25 00:00:00
+Thursday 2009-07-30 00:00:00
+Thursday 2009-08-27 00:00:00
+Thursday 2009-09-24 00:00:00
+Thursday 2009-10-29 00:00:00
+Thursday 2009-11-26 00:00:00
+Thursday 2009-12-31 00:00:00