ID: 40271
Updated by: [EMAIL PROTECTED]
Reported By: slomo at sonarkollektiv dot de
Status: Bogus
Bug Type: Date/time related
Operating System: Mac OS X 10.4.8
PHP Version: 5.2.0
New Comment:
It should be
"1999-01-04 UTC + **0** week last monday" means "1999-01-04 minus 1
week" (because 1999-01-04 is monday).
Previous Comments:
------------------------------------------------------------------------
[2007-01-29 14:38:20] slomo at sonarkollektiv dot de
> Your expectation is wrong.
> 1999-01-04 is Monday, so "last monday" for 1999-01-04 is
"1999-01-04
> minus 1 week" and "last monday" 1999-01-11 is 1999-01-04.
I still do not agree. I expect:
code :
strtotime("1999-01-04 UTC + 1 week last monday");
strtotime("1999-01-11 UTC + 0 week last monday");
1999-01-04 is monday
1999-01-11 is monday too
If you say:
"1999-01-04 UTC + 1 week last monday" means "1999-01-04
minus 1 week" (because 1999-01-04 is monday)
you forgot to mention the "+ 1 week" in the expression, this
makes "1999-01-04 minus 1 week plus 1 week" for me
= 1999-01-04 , or?
following you explanation
"1999-01-11 UTC + 0 week last monday" then means "1999-01-11
minus 1 week" (because 1999-01-11 is monday too)
and again we have to consider "+ 0 week", this makes
"1999-01-11 minus 1 week plus 0 week" for me
= 1999-01-04 , or do I miss something?
Next test:
code :
strtotime("1999-01-04 UTC + 0 week last monday");
strtotime("1999-01-04 UTC + 1 week last monday");
strtotime("1999-01-04 UTC + 2 week last monday");
actual result:
914803200
916012800
916617600
expected result:
at least always the same gap (604800 is a week), but it
differs
> See previous explanation.
> No bug here.
This answer is even more confusing for me.
1999-01-04 is monday, correct?
no matter how you turn it, either
"1999-01-04 last monday" = 1998-12-28 + X weeks =
something with always the same gap
or
"1999-01-04" + X weeks = a date, and a monday too -> now
apply "last monday" = something with always the same gap
(we are working with a monday, no matter how you turn it, so
I expect strtotime() to behave alike, the only differing
value is the "+ X weeks")
I still expect "something with always the same gap". Sorry
for my stubbornness :(
At the moment I see that
strtotime("1999-01-11 UTC last monday + 1 week")
and
strtotime("1999-01-11 UTC + 1 week last monday")
are giving different results ... now I give up :)
Thank you for your support even more for the neat solution
using strtotime('2007W011').
------------------------------------------------------------------------
[2007-01-29 13:25:17] [EMAIL PROTECTED]
code :
>strtotime('1999-01-04 UTC + 1 week last monday');
>strtotime('1999-01-11 UTC + 0 week last monday');
>actual result:
>916012800
>915408000
>expected result:
>at least the same value
Your expectation is wrong.
1999-01-04 is Monday, so "last monday" for 1999-01-04 is "1999-01-04
minus 1 week" and "last monday" 1999-01-11 is 1999-01-04.
>expected result:
>at least always the same gap (604800 is a week), but it
>differs
See previous explanation.
No bug here.
------------------------------------------------------------------------
[2007-01-29 13:20:01] slomo at sonarkollektiv dot de
Just to point out why I think somethings weird, compare the
previous code and result to this one.
code:
strtotime('2000-01-04 UTC + 1 week last monday');
strtotime('2000-01-11 UTC + 0 week last monday');
actual result:
947462400
947462400
expected result:
947462400
947462400
> same value, fine.
And the same for
code:
strtotime('2000-01-04 UTC + 0 week last monday');
strtotime('2000-01-04 UTC + 1 week last monday');
strtotime('2000-01-04 UTC + 2 week last monday');
actual result:
946857600
947462400
948067200
expected result:
946857600
947462400
948067200
> always the same gap (604800 is a week), fine.
------------------------------------------------------------------------
[2007-01-29 12:22:42] slomo at sonarkollektiv dot de
code :
strtotime('1999-01-04 UTC + 1 week last monday');
strtotime('1999-01-11 UTC + 0 week last monday');
actual result:
916012800
915408000
expected result:
at least the same value
Another example
code :
strtotime('1999-01-04 UTC + 0 week last monday');
strtotime('1999-01-04 UTC + 1 week last monday');
strtotime('1999-01-04 UTC + 2 week last monday');
actual result:
914803200
916012800
916617600
expected result:
at least always the same gap (604800 is a week), but it
differs
------------------------------------------------------------------------
[2007-01-29 12:02:37] slomo at sonarkollektiv dot de
thanks [EMAIL PROTECTED], that's brilliant :)
and it seems to be bug free. I still think my code produced a
bug in PHP and I do not get why this happens.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/40271
--
Edit this bug report at http://bugs.php.net/?id=40271&edit=1