Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Hakala on March 27, 2012, 05:34:01 AM

Title: Week 52 and 1 overlap when monday first day of the week
Post by: Hakala on March 27, 2012, 05:34:01 AM
I recently installed 2.0.2 and now when browsing the calendar found that week numbers didn't match. After changing the setting where monday is the first day of the week I noticed that week 52/2011 ended on sunday which also appeared to start week 1.
Can anyone verify this?

Mods installed:
SimplePortal 2.3.5 RC1
Aeva Media 1.4w
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: emanuele on March 27, 2012, 05:42:21 AM
Hello Hakala and welcome to sm.org!

I think I've already seen the problem reported somewhere, probably not here, though.

/me goes looking for the other topic to see if it is the same.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Hakala on March 27, 2012, 06:49:46 AM
Quote from: emanuele on March 27, 2012, 05:42:21 AM
Hello Hakala and welcome to sm.org!
Thank you!

Quote from: emanuele on March 27, 2012, 05:42:21 AM
I think I've already seen the problem reported somewhere, probably not here, though.

/me goes looking for the other topic to see if it is the same.
I also did a quick search before posting but didn't find anything similar. It's good to know the issue might not be in my setup here.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: emanuele on March 27, 2012, 07:52:19 AM
Okay, well...what I had in mind was a bit hidden... :P

Could be something like that (http://www.simplemachines.org/community/index.php?topic=446776.msg3243439#msg3243439)?
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Hakala on March 27, 2012, 03:51:17 PM
Quote from: emanuele on March 27, 2012, 07:52:19 AM
Could be something like that (http://www.simplemachines.org/community/index.php?topic=446776.msg3243439#msg3243439)?

Ummm... no. But that's weird too. ;D
Something like in the attached picture.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: emanuele on March 27, 2012, 04:56:32 PM
Sorry, wrong copy&paste! lol

http://www.simplemachines.org/community/index.php?topic=124987.msg3274469#msg3274469
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Hakala on March 27, 2012, 05:11:14 PM
:laugh:
Well that's starting to look more like what I'm dealing with...
I guess there hasn't been any breakthroughs on this issue lately?
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: emanuele on March 29, 2012, 05:23:31 AM
Not really... :laugh: ...
I was looking at few other things.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Joshua Dickerson on April 17, 2012, 09:40:25 AM
That is not the last day of week 52. That is the first day of a new year. The way it is, is correct.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: emanuele on April 18, 2012, 07:48:06 AM
Not really, as far as I can see around the internet and on my (KDE) calendar (see the attachments) where the 1st of January is considered part of the last week of the previous year (week 52), while the 2nd of January is in the 1st week of the year.
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Thantos on April 18, 2012, 10:41:33 AM
Like all date and calendar issues it is regional.  But ISO 8601 does define how the weeks are counted.  And the first week is the week that contains the first Thursday.


<?php

$dates 
= array(
'Jan 1, 2007'// Monday
'Jan 1, 2008'// Tues
'Jan 1, 2014'// Wed
'Jan 1, 2009'// Thur
'Jan 1, 2010'// Fri
'Jan 1, 2011'// Sat
'Jan 1, 2012'// Sun
);

echo 
'
<ul>'
;

foreach (
$dates AS $date)
{
$ts strtotime($date);
echo '<li>'$date': 'date('N W'$ts), '</li>';  // N is the day of the week, W is the week number
}

echo 
'
</ul>'
;
Title: Re: Week 52 and 1 overlap when monday first day of the week
Post by: Arantor on January 27, 2014, 03:10:12 PM
We had a long, long discussion about this internally. If you look, SMF's week calculation code was actually broken. First week of January 2012 showed some crazy stuff - where you could cause it to display week beginning Monday 2nd January as week 2.

I did some experimentation with using the ISO 8601 code, but with weeks beginning on Sunday this always looked wrong for US users, because it always ends up needing to display 'week numbers' on Mondays.

In the end, we concluded it was better to simply just remove that week number listing rather than trying to fix it because for a significant number of users it will look wrong even if it is correct. Especially because some people didn't (understandably) like the idea of showing 1st January 2012 as Week 52 even though it is week 52 of 2011 - because of how it would look confusing (even if correct), we just realised that just removing it was best.

For the weekly view, instead of saying 'Week x of y' it now says 'Week beginning December 26, 2011' or whatever would be appropriate.