topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 5:33 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Windows 7 Breaks Week Numbering  (Read 9714 times)

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Windows 7 Breaks Week Numbering
« on: January 16, 2011, 04:37 PM »
Okay, so I got a bugg report regarding week numbering being wrong on T-Clock 2010's pop-up calendar (after Jan 2011). Now the calendar gets its week numbering from the Windows system ... So it should be impossible to screw up... Ha!

I first confirmed that the week numbering was indeed wrong ... Which is odd because it was right just last week/year...

Now here's the weird part:
Outlook 2007's calendar running on my Win7 x64 development machine, also displays the week number incorrectly. But, the WinXP VPC running on the same machine shows the week numbers correctly.

Saturday, January 1st, should be week 0, as the MSDN states (in the documentation for the Calendar Control) that week 1 is the first week of the year with 4 days in it. But Windows 7 appears to want to call it week 1. Which (of course) throws off the week numbering for the entire year.

Has anyone else heard of, or ran across this bizarre behavior?


Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #1 on: January 17, 2011, 01:52 AM »
AFAIK, January 1st and 2nd are part of week 52 of last year or indeed week 0 of this year, depending on convention. This with Monday being the first day of the week, that is ;)
I've been implementing this 'week' (or was it 'weak' :-[) function some 15 years ago, and had kind of the same trouble then, but without the internet to search it was a lot harder to find a proper solution... eventually the 3 or 4 day minimum length (depending on Sunday or Monday as the first weekday) for week 1 popped up, and I was able to resolve it by dropping the extra days in week 52/53 of last year. Week 0 has always seemed quite impossible to me...
Though it looked odd to me for a long time, I've just been ignoring the 'strange' week numbers at the start of the year, but ofcourse in my case there's nothing life-threatening depending on it.

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #2 on: January 17, 2011, 02:12 AM »
Saturday, January 1st, should be week 0, as the MSDN states (in the documentation for the Calendar Control) that week 1 is the first week of the year with 4 days in it. But Windows 7 appears to want to call it week 1. Which (of course) throws off the week numbering for the entire year.

Can you post some code (or be quite specific about the Calendar control/class you're using)?  The MSDN docs for the Calendar class's `GetWeekOfYear()` method indicate that you have to pass in a CalendarWeekRule that would specify whether the 1st week:

  • starts on the first day of the year
  • is the first full week
  • is the first with 4 days in it

Are you using something else, or could you possibly be passing in the wrong CalendarWeekRule value?

See http://msdn.microsof...r.getweekofyear.aspx

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #3 on: January 17, 2011, 02:16 AM »
Has anyone else heard of, or ran across this bizarre behavior?

I had this problem a year ago with AHK. See this thread:

http://www.autohotke...iewtopic.php?t=55056

There's a registry setting to change this behavior, but I guess it would be best if your tool isn't relying on Windows, but calculates the week numbers on its own following this iso standard.


Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #4 on: January 17, 2011, 05:19 PM »
Curiouser and curiouser this gets...

Just as a recap; There are three sources of week numbering I'm working with:
T-Clock's Custom Format String, which has been correct throughout the testing.
MS Outlook's Calendar (Both 2007 & 2010), which has been wrong throughout the testing.
T-Clock's Pop-up Calendar, which was wrong ... But now displays correctly after setting wr975 regestry key: HKEY_CURRENT_USER\Control Panel\International\iFirstWeekOfYear to 1.

Can you post some code (or be quite specific about the Calendar control/class you're using)?

Well.. T-Clock is still being compiled as pure C code - (Stop Laughing...) - So the only code used to create the control is this:
Code: C [Select]
  1. case WM_INITDIALOG: // Display 1 Month, 3 Months, or Full Year Calendar
  2.                 ivMonths = GetMyRegLongEx("Calendar", "ViewMonths", 1); // New Feature - Coming Soon!
  3.  
  4.           if(GetMyRegLong("Calendar", "ShowWeekNums", FALSE)) {
  5.                   dwCalStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|MCS_NOTODAYCIRCLE|MCS_WEEKNUMBERS;
  6.           }else{
  7.                   dwCalStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|MCS_NOTODAYCIRCLE;
  8.           }
  9.  
  10.           hCal = CreateWindowEx(0, MONTHCAL_CLASS, "", dwCalStyle, 0,0,0,0, hDlg, 0, 0, NULL);

The calendar control defaults to today's date, so there really isn't any provision for feeding it (anything) GetWeekOfYear() - Which I seem to recall using successfully elseware in the Custom Format String code.

The question at this point, is if I add an option to adjust wr975's iFirstWeekOfYear registry entry ... Will that create a potential problem for other applications running on the user's machine?? (e.g. Sure it's easy as hell to do, but should it be done?)

Side Note:
Both the XP VPC and the Win7 Host machine started with a default value of 0 for iFirstWeekOfYear.
XP numbers the weeks correctly with either 1 or 0 as a value.
Win7 (both x86 & x64) required iFirstWeekOfYear to be set to 1.

*Shrug* ...7 is broken?
« Last Edit: January 17, 2011, 05:25 PM by Stoic Joker »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #5 on: January 17, 2011, 10:20 PM »
Windows 7 is broken?

On way too many low levels...it is not even funny anymore.

I keep telling that Windows 7 is not ready for the enterprise, the PC's that have to work with big names like Peoplesoft, SAP, eBase. It still amazes me how much is broken and is/has to be rewritten to get the previous functionality (from pre-Vista OS's) back.

For general use Windows 7 is a sufficient replacement for the aging XP. That is as far as I want to go with it. I understand that SP1 is coming soon for 7, I really hope they sorted out the mess they created, but will not keep my breath...

It is not like I am not trying to like 7...as I am using it on my personal PC, but the problems I keep encountering are sure dampening the fun.

Talking about fun, try Oracle 11g Database server software on Windows 7 (or Win 2008 R2 for that matter). Now try to access that database with 3rd party software. 80% chance that you are locked out each time the app access it. Networking issue with Windows 7/Win 2008 R2 is the cause.

Yeah, I know, I know, time to consider using Microsoft's SQL server... *shrug*

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #6 on: January 17, 2011, 10:37 PM »
Just had to get that off your chest, did Ya?

 :D

I haven't tried anything with Oracle, but I've had really good luck with other databases (MySQL, Pervasive SQL, Advantage Database Server, and yes MSSQL) on Server 2k8.

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #7 on: January 18, 2011, 05:25 AM »
The question at this point, is if I add an option to adjust wr975's iFirstWeekOfYear registry entry ... Will that create a potential problem for other applications running on the user's machine?? (e.g. Sure it's easy as hell to do, but should it be done?)
*Shrug* ...7 is broken?

Probably not, because if an (European) user wants the ISO week number, then it should be set to "2" anyway. (I've googled a bit)

iFirstWeekOfYear = "Specifies which week of the year is considered first.
0 - Week containing January 1 is the first week of the year.
1 - First full week following January 1 is the first week of the year.
2 - First week containing at least four days is the first week of the year."

On Win XP this registry setting seems to be ignored. So... is XP broken ?  ;D
« Last Edit: January 18, 2011, 05:27 AM by wr975 »

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #8 on: January 18, 2011, 06:04 AM »
The question at this point, is if I add an option to adjust wr975's iFirstWeekOfYear registry entry ... Will that create a potential problem for other applications running on the user's machine?? (e.g. Sure it's easy as hell to do, but should it be done?)
*Shrug* ...7 is broken?

Probably not, because if an (European) user wants the ISO week number, then it should be set to "2" anyway. (I've googled a bit)
I was in the process of arriving at that conclusion also ... As I too was Googling ... But decided I'd googled enough, when I realized that I'd been steadily (but unconsciously) swearing in Bavarian for over half an hour. :huh:

...Let's call it a feature! ;)

iFirstWeekOfYear = "Specifies which week of the year is considered first.
0 - Week containing January 1 is the first week of the year.
1 - First full week following January 1 is the first week of the year.
2 - First week containing at least four days is the first week of the year."

On Win XP this registry setting seems to be ignored. So... is XP broken ?  ;D

Hm... So if XP is the broken one, then 7 can go back to being perfect ... I like it! And, it fits perfectly with my warped version of reality...
    

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #9 on: January 18, 2011, 06:08 AM »
Shades: what makes you say those issues are because of Win7, and not the 3rd party software? I definitely wouldn't put it past SAP and Oracle software to be shoddily coded.
- carpe noctem

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #10 on: January 18, 2011, 10:30 AM »
@f0dder:
Because these apps do not experience problems on Vista and 2008 R1 operating systems. Which is what makes me say that Windows is (unintentionally?) breaking things.

Granted, you are probably right about other apps being shoddily coded, but I have here an 3rd party app that just uses one oracle dll to connect to Oracle and that is it. That 3rd party app also communicates successfully with SAP on any os except with Win7 and Win 2008 R2.

CWuestefeld

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,009
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #11 on: January 18, 2011, 11:10 AM »
This sounds the same as a bug in VB5 I submitted to Microsoft, a couple of eons back. The problem isn't with the OS, but with the library.

In some years, the end of the last week of the old year extends into Jan 1, Jan 2, etc. If you ask about the week # with respect to the old year, you get the right answer (that it's wk 53 or whatever). But if you ask that same question with respect to the new year (i.e., "what's the week number for Jan1, 2011"), then it assumes that it's part of the new year, without considering that it might be the old year's dying days.

Microsoft said that this was the intended behavior, and declined to fix it.  :huh:

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #12 on: January 18, 2011, 11:48 AM »
This sounds the same as a bug in VB5 I submitted to Microsoft, a couple of eons back. The problem isn't with the OS, but with the library.
Interesting, but this is a pure C project, using the Windows Common Controls - so there is no additional runtime library to speak of - Not to mention the behavioral change between OS's ... But I'm with you in spirit. :)

In some years, the end of the last week of the old year extends into Jan 1, Jan 2, etc. If you ask about the week # with respect to the old year, you get the right answer (that it's wk 53 or whatever). But if you ask that same question with respect to the new year (i.e., "what's the week number for Jan1, 2011"), then it assumes that it's part of the new year, without considering that it might be the old year's dying days.
One of the first things I discovered when I started down the add week numbers to the project path ... Was that the only thing that week numbering did consistently, according to the ISO standard, was change... Sure for the most part they have it down to the three most likely suspects. But they don't always fit into the regional(ization) borders because of the multitude of who likes what where combinations. There are actually 3 areas (globally speaking/I forget the country names), that require that you basically wing-it week number wise.

Microsoft said that this was the intended behavior, and declined to fix it.  :huh:

I got a funny feeling that the (apparently little known) registry entry that wr975 came up with was the MS "fix" for said issue. I say this because it was only after following wr975's links that I found the week number wing-it in 3 countries rest-of-the-story...detail. Which is what compelled me into an Ah-Ha moment corner, and lead to my decision to leverage that setting as the only sane option ... Because (according to MS) that's exactly what it's for.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #13 on: January 18, 2011, 02:31 PM »
@f0dder:
Because these apps do not experience problems on Vista and 2008 R1 operating systems. Which is what makes me say that Windows is (unintentionally?) breaking things.
...and there's plenty of examples of code that works on Win9x but breaks on WinNT, or works on Win2000 but breaks on WinXP (et cetera), because developers of said software made assumptions that violate the specs...

Not saying it isn't a Windows bug, but I find it more reasonable to start blaming the 3rd party developers first :)
- carpe noctem

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #14 on: January 18, 2011, 10:49 PM »
@f0dder:
Being not too proud to admit I could be wrong in my assumptions or logic, I will agree with you. Let's also stop pulling the thread off-topic.

@Stoic Joker:
Indeed, it is/was my frustration speaking. Sorry about that.


Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: Windows 7 Breaks Week Numbering
« Reply #15 on: January 19, 2011, 05:36 AM »
@f0dder:
Being not too proud to admit I could be wrong in my assumptions or logic, I will agree with you. Let's also stop pulling the thread off-topic.
Aw shit, I was rather enjoying that discussion too...

@Stoic Joker:
Indeed, it is/was my frustration speaking. Sorry about that.
[/quote]

*Shrug* That's cool ... hell it was my frustration that started the thread ... but I'm done now (i think). So carry on with f0dder I was actually following that bit with great interest. :)