Skip to content

fix bug 63392 #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ext/date/lib/tm2unixtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ static void do_adjust_for_weekday(timelib_time* time)
current_dow = timelib_day_of_week(time->y, time->m, time->d);
if (time->relative.weekday_behavior == 2)
{
if (time->relative.weekday == 0) {
time->relative.weekday = 7;
}
time->d -= current_dow;
time->d += time->relative.weekday;
return;
Expand Down
17 changes: 17 additions & 0 deletions ext/date/tests/bug63392.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #63392 (DateTime::modify() start of week inconsistency)
Description:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use DESCRIPTION Section like this:
https://github.com/php/php-src/blob/master/Zend/tests/bug60825.phpt#L1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already corrent the mistake that you said above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I mean you could move the description to a new section, or it will output with the test name, that looks ugly :)

--DESCRIPTION--
......

------------


--INI--
date.timezone=UTC
--FILE--
<?php

$dt = new DateTime("2012-05-13");
$dt->modify("Sunday this week");
var_dump($dt->format('r'));
?>
--EXPECT--
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output is timezone dependent, you could add a timezone section, eg:

--INI--
date.timezone=UTC
--FILE--
<?php
....

on my machine test failed before set timezone:

001+ string(31) "Sun, 13 May 2012 00:00:00 +0800"
001- string(31) "Sun, 13 May 2012 00:00:00 +0000"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php's version that you used is error plesae use the last version. php 5.3.x will cause timezone dependent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use PHP5.4-lastest and test should pass in all currently maintained version :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake ,you are right,many php version on my PC,i confuse the version,sorry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already add ini date.timezone=UTC.

string(31) "Sun, 13 May 2012 00:00:00 +0000"