diff options
author | Derick Rethans <derick@php.net> | 2008-08-05 18:02:39 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2008-08-05 18:02:39 +0000 |
commit | 7772d56fabec67316f15e02b5fdc61c5cb8508f4 (patch) | |
tree | a12ab1fab1033afb527e79892865f4a1c7b72ebb | |
parent | 682bcde37b74798c2e81f3fdf941b0f68600b5ac (diff) | |
download | php-git-7772d56fabec67316f15e02b5fdc61c5cb8508f4.tar.gz |
- Fixed a bug that caused miscalculations with the "last <weekday> of <n>
month" relative time string.
-rw-r--r-- | ext/date/lib/tm2unixtime.c | 1 | ||||
-rw-r--r-- | ext/date/tests/date_period.phpt | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index 458baca0ab..1ba4439d04 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -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 index 0000000000..65dd1b1274 --- /dev/null +++ b/ext/date/tests/date_period.phpt @@ -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 |