ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#50105 [Opn->Bgs]: strtotime, strftime, weekday & monday & year leap
by derick other posts by this author
Nov 6 2009 1:40PM messages near this date
#50105 [NEW]: strtotime, strftime, weekday & monday & year leap | #50102 [NEW]: With CGI/FastCGI, auto_prepend_file and auto_append_file duplication.
ID:               50105
 Updated by:       derick@[...].net
 Reported By:      tcheko at no-log dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux
 PHP Version:      5.3.0
 New Comment:

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

You're doing it wrong, please read:

       %G     The ISO 8601 week-based year (see NOTES) with century as
a deci‐
              mal number.  The 4-digit year corresponding to the ISO
week num‐
              ber  (see %V).  This has the same format and value as %Y,
except
              that if the ISO week number belongs  to  the  previous 
or  next
              year, that year is used instead. (TZ)

NOTES
   ISO 8601 Week Dates
       %G, %g, and %V yield values calculated from the week-based year
defined
       by the ISO 8601 standard.  In this system, weeks start on a
Monday, and
       are numbered from 01, for the first week, up to 52 or 53, for
the  last
       week.  Week 1 is the first week where four or more days fall
within the
       new year (or, synonymously, week 01 is: the first week of the
year that
       contains  a  Thursday;  or,  the  week that has 4 January in
it).  When
       three of fewer days of the first calendar week of  the  new 
year  fall
       within that year, then the ISO 8601 week-based system counts
those days
       as part of week 53 of the preceding year.  For example, 1
January  2010
       is a Friday, meaning that just three days of that calendar week
fall in
       2010.  Thus, the ISO 8601 week-based system considers these days
to  be
       part  of  week 53 (%V) of the year 2009 (%G) ; week 01 of ISO
8601 year
       2010 starts on Thursday, 4 January 2010.



Previous Comments:
------------------------------------------------------------------------

[2009-11-06 21:12:11] tcheko at no-log dot org

Description:
------------
This code fails on two weeks. Week 1, year printed is 2009 instead of
dec 29 2008 and week 52, year printed is 2009 instead of Jan 3 2010.

Bug or feature or am I doing something wrong ?
 

Reproduce code:
---------------
setlocale(LC_ALL, "fr_FR.utf8");
date_default_timezone_set("Europe/Paris");

// Get the number of weeks in a year
$weeks = date("W", mktime(0,0,0,12,31, 2009));
// print the 1st monday of each week with year
for($i=1; $i <= $weeks; $i++)
{
	if(strlen($i) == 1) $w = "0" . $i; else $w = $i;
	echo strftime("%A %e %B %G", strtotime("2009W$w")) . " - "
.strftime("%A %e %B %G", strtotime("2009W$w +6days"));
}



Expected result:
----------------
lundi 28 d�cembre 2008 instead of lundi 28 d�cembre 2009

dimanche 3 janvier 2010 instead of dimanche 3 janvier 2009


Actual result:
--------------
Actual code output. Submitted code stripped to revelant part only.

Semaine n�1 du lundi 29 d�cembre 2009 au dimanche 4 janvier 2009
Semaine n�53 du lundi 28 d�cembre 2009 au dimanche 3 janvier 2009


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


-- 
Edit this bug report at http://bugs.php.net/?id=50105&edit=1
Thread:
Tcheko At No-Log Dot Org
derick

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved