[PHP-BUG] Bug #54505 [NEW]: Date("Y") for Dec returns incorrectly

2011-04-11 Thread josh dot reinert at gmail dot com
From: 
Operating system: Windows 7
PHP version:  5.3.6
Package:  Date/time related
Bug Type: Bug
Bug description:Date("Y") for Dec returns incorrectly

Description:

I am actually running PHP 5.3.5 on Apache 2.2 on Windows 7 as my
development machine.



php.net states:

W   ISO-8601 week number of year, weeks starting on Monday (added in PHP
4.1.0)



I have a calender class that I created that lists the weeks of the year for
a given month.  For certain years when January 1st is not on Sunday or
Monday the date function is returning that it is still on the first week of
the year where if the weeks start on Monday it should be returning the last
week of the previous year.  This then offsets the rest of the year.  I
noticed it when I had a Dec. with week 54.

Test script:
---
for ($i=2000; $i<2040; $i++){

// Week of the Year

$WoY = (int) date("W", mktime(0, 0, 0, 1, 1, $i));

// Day of Jan 1st

$DoM = date("l", mktime(0, 0, 0, 1, 1, $i));

// If the week is 1 then the day must be either Sunday or Monday;
otherwise we are still in the previous year

if ($WoY == 1 && !($DoM == "Monday" || $DoM == "Sunday"))

print "$DoM Jan 1, $i is on week $WoY\n\n";



}

Expected result:



Actual result:
--
Tuesday Jan 1, 2002 is on week 1

Wednesday Jan 1, 2003 is on week 1

Thursday Jan 1, 2004 is on week 1

Tuesday Jan 1, 2008 is on week 1

Thursday Jan 1, 2009 is on week 1

Tuesday Jan 1, 2013 is on week 1

Wednesday Jan 1, 2014 is on week 1

Thursday Jan 1, 2015 is on week 1

Tuesday Jan 1, 2019 is on week 1

Wednesday Jan 1, 2020 is on week 1

Wednesday Jan 1, 2025 is on week 1

Thursday Jan 1, 2026 is on week 1

Tuesday Jan 1, 2030 is on week 1

Wednesday Jan 1, 2031 is on week 1

Thursday Jan 1, 2032 is on week 1

Tuesday Jan 1, 2036 is on week 1

Thursday Jan 1, 2037 is on week 1

Wednesday Jan 1, 2039 is on week 1 

-- 
Edit bug report at http://bugs.php.net/bug.php?id=54505&edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54505&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54505&r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=54505&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54505&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54505&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54505&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=54505&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=54505&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=54505&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=54505&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=54505&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=54505&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=54505&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54505&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=54505&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=54505&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=54505&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=54505&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=54505&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=54505&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=54505&r=mysqlcfg



Bug #54505 [Opn]: Date("Y") for certain years returns incorrectly

2011-04-11 Thread josh dot reinert at gmail dot com
Edit report at http://bugs.php.net/bug.php?id=54505&edit=1

 ID: 54505
 User updated by:josh dot reinert at gmail dot com
 Reported by:josh dot reinert at gmail dot com
-Summary:Date("Y") for Dec returns incorrectly
+Summary:Date("Y") for certain years returns incorrectly
 Status: Open
 Type:   Bug
 Package:Date/time related
 Operating System:   Windows 7
 PHP Version:5.3.6
 Block user comment: N
 Private report: N

 New Comment:

Trying to modify the summary since it affects the year not just the
month


Previous Comments:
----
[2011-04-11 16:35:45] josh dot reinert at gmail dot com

Description:

I am actually running PHP 5.3.5 on Apache 2.2 on Windows 7 as my
development machine.



php.net states:

W   ISO-8601 week number of year, weeks starting on Monday (added in PHP
4.1.0)



I have a calender class that I created that lists the weeks of the year
for a given month.  For certain years when January 1st is not on Sunday
or Monday the date function is returning that it is still on the first
week of the year where if the weeks start on Monday it should be
returning the last week of the previous year.  This then offsets the
rest of the year.  I noticed it when I had a Dec. with week 54.

Test script:
---
for ($i=2000; $i<2040; $i++){

// Week of the Year

$WoY = (int) date("W", mktime(0, 0, 0, 1, 1, $i));

// Day of Jan 1st

$DoM = date("l", mktime(0, 0, 0, 1, 1, $i));

// If the week is 1 then the day must be either Sunday or Monday;
otherwise we are still in the previous year

if ($WoY == 1 && !($DoM == "Monday" || $DoM == "Sunday"))

print "$DoM Jan 1, $i is on week $WoY\n\n";



}

Expected result:



Actual result:
--
Tuesday Jan 1, 2002 is on week 1

Wednesday Jan 1, 2003 is on week 1

Thursday Jan 1, 2004 is on week 1

Tuesday Jan 1, 2008 is on week 1

Thursday Jan 1, 2009 is on week 1

Tuesday Jan 1, 2013 is on week 1

Wednesday Jan 1, 2014 is on week 1

Thursday Jan 1, 2015 is on week 1

Tuesday Jan 1, 2019 is on week 1

Wednesday Jan 1, 2020 is on week 1

Wednesday Jan 1, 2025 is on week 1

Thursday Jan 1, 2026 is on week 1

Tuesday Jan 1, 2030 is on week 1

Wednesday Jan 1, 2031 is on week 1

Thursday Jan 1, 2032 is on week 1

Tuesday Jan 1, 2036 is on week 1

Thursday Jan 1, 2037 is on week 1

Wednesday Jan 1, 2039 is on week 1 






-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54505&edit=1


Bug #54505 [Bgs]: Date("Y") for certain years returns incorrectly

2011-04-11 Thread josh dot reinert at gmail dot com
Edit report at http://bugs.php.net/bug.php?id=54505&edit=1

 ID: 54505
 User updated by:josh dot reinert at gmail dot com
 Reported by:josh dot reinert at gmail dot com
 Summary:Date("Y") for certain years returns incorrectly
 Status: Bogus
 Type:   Bug
 Package:Date/time related
 Operating System:   Windows 7
 PHP Version:5.3.6
 Block user comment: N
 Private report: N

 New Comment:

Oh wow, sorry Derick. I miss interpreted the "weeks start on Monday" to
include the first of the year.  As for what I am trying to do, our
company uses the weeks of the year to calculate the "Month's End".  Our
weeks actually start on Sunday's and according to one of our Accountants
the first Sunday of the year is week 1.  I apologize for submitting a
bad report.  Thank you for the information.


Previous Comments:

[2011-04-11 16:58:44] der...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Uh, what are you trying to do here? The year is the ISO-year, and the W
an ISO-week number. Please read up on how that works here:
http://en.wikipedia.org/wiki/ISO_year#Relation_with_the_Gregorian_calendar

----------------
[2011-04-11 16:39:32] josh dot reinert at gmail dot com

Trying to modify the summary since it affects the year not just the
month

----------------
[2011-04-11 16:35:45] josh dot reinert at gmail dot com

Description:

I am actually running PHP 5.3.5 on Apache 2.2 on Windows 7 as my
development machine.



php.net states:

W   ISO-8601 week number of year, weeks starting on Monday (added in PHP
4.1.0)



I have a calender class that I created that lists the weeks of the year
for a given month.  For certain years when January 1st is not on Sunday
or Monday the date function is returning that it is still on the first
week of the year where if the weeks start on Monday it should be
returning the last week of the previous year.  This then offsets the
rest of the year.  I noticed it when I had a Dec. with week 54.

Test script:
---
for ($i=2000; $i<2040; $i++){

// Week of the Year

$WoY = (int) date("W", mktime(0, 0, 0, 1, 1, $i));

// Day of Jan 1st

$DoM = date("l", mktime(0, 0, 0, 1, 1, $i));

// If the week is 1 then the day must be either Sunday or Monday;
otherwise we are still in the previous year

if ($WoY == 1 && !($DoM == "Monday" || $DoM == "Sunday"))

print "$DoM Jan 1, $i is on week $WoY\n\n";



}

Expected result:



Actual result:
--
Tuesday Jan 1, 2002 is on week 1

Wednesday Jan 1, 2003 is on week 1

Thursday Jan 1, 2004 is on week 1

Tuesday Jan 1, 2008 is on week 1

Thursday Jan 1, 2009 is on week 1

Tuesday Jan 1, 2013 is on week 1

Wednesday Jan 1, 2014 is on week 1

Thursday Jan 1, 2015 is on week 1

Tuesday Jan 1, 2019 is on week 1

Wednesday Jan 1, 2020 is on week 1

Wednesday Jan 1, 2025 is on week 1

Thursday Jan 1, 2026 is on week 1

Tuesday Jan 1, 2030 is on week 1

Wednesday Jan 1, 2031 is on week 1

Thursday Jan 1, 2032 is on week 1

Tuesday Jan 1, 2036 is on week 1

Thursday Jan 1, 2037 is on week 1

Wednesday Jan 1, 2039 is on week 1 






-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54505&edit=1